I'm trying to make some sort of a primitive form on what I'd optimize to be an interactive BMI calculator I guess. So this is my code.
CODE:
import java.util.Scanner;
class bmi{
public static void main(String args[]) {
Scanner userinput = new Scanner(System.in);
double weight, height, bmi;
String sex;
System.out.println("Hello there!");
System.out.println("I am your Body-Mass index calculator!");
System.out.println("Would you please be so kind and tell me your weight? In kilograms if possible, I'm from Europe xD.");
weight = userinput.nextDouble();
System.out.println("Alrighty, now tell me, how tall are you? In meters this time.");
height = userinput.nextDouble();
System.out.println("Finally, can you tell me wether you are a boy or a girl, if that isn't too intrusive... *wink*");
sex = userinput.nextLine();
bmi = weight / (height * height);
if (sex = "boy") {
System.out.println("Thank you for providing me this information, bro!");
System.out.println(" ");
System.out.println("Hmm, it looks like your results came...");
}
else {
System.out.println("Thanks for the indormation, sys! ;)");
System.out.println(" ");
System.out.println("Hmm, it looks like your results came...");
}
System.out.println(" ");
if (bmi <= 18.5 && sex = "boy") {
System.out.println("Looking just at your height and weight, I can tell you are a skinny guy, in fact the data (your BMI is "bmi") shows that you are underweight. You might consider gaining some wight, it would be best for your health.");
}
else if (bmi <= 25 && sex = "boy") {
System.out.println("Damn son, you're looking good (in numbers xD)! With a BMI of "bmi", you are just about average, nothing to worry about here!);
}
else if (bmi <= 18.5 && sex = "girl") {
System.out.println("Looking at the numbers you gave me, it seems that you are underweight :/, in fact with a bmi of "bmi",your weight is below that of an average girl. Not having considered your age, there is no way I can tell you wether the condition is critical or not, but you should really consider gaining some weight.");
}
else if (bmi <= 25 && sex = "girl") {
System.out.println("Damn giiiirl, you rock! Having a BMI of "bmi", you are an ideal specimen of a healthy female figure. Keep it up!);
}
else if (bmi > 25 && sex = "girl") {
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.);
}
else if (bmi > 25 && sex = "boy") {
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.);
}
else if (bmi > 30) then {
System.out.println("I am so sorry to be the one to inform you, but with a BMI of "bmi",you are consiered obese by the National Health Orgnaization, at this point, your weight might be seriously affecting your health, and I strongly suggest you to take on a diet, start working out or if the case is extreme, seek professional help. Do it for yourself, I believe in you! <3");
}
System.out.println(" ");
System.out.println("Thank you for letting me help!");
}
}
OK, and now here is the report:
javac JavaTutorial.java
JavaTutorial.java:39: error: ')' expected
System.out.println("Looking just at your height and weight, I can tell you are a skinny guy, in fact the data (your BMI is "bmi") shows that you are underweight. You might consider gaining some wight, it would be best for your health.");
^
JavaTutorial.java:39: error: not a statement
System.out.println("Looking just at your height and weight, I can tell you are a skinny guy, in fact the data (your BMI is "bmi") shows that you are underweight. You might consider gaining some wight, it would be best for your health.");
^
JavaTutorial.java:39: error: ';' expected
System.out.println("Looking just at your height and weight, I can tell you are a skinny guy, in fact the data (your BMI is "bmi") shows that you are underweight. You might consider gaining some wight, it would be best for your health.");
^
JavaTutorial.java:43: error: ')' expected
System.out.println("Damn son, you're looking good (in numbers xD)! With a BMI of "bmi", you are just about average, nothing to worry about here!);
^
JavaTutorial.java:43: error: unclosed string literal
System.out.println("Damn son, you're looking good (in numbers xD)! With a BMI of "bmi", you are just about average, nothing to worry about here!);
^
JavaTutorial.java:43: error: ';' expected
System.out.println("Damn son, you're looking good (in numbers xD)! With a BMI of "bmi", you are just about average, nothing to worry about here!);
^
JavaTutorial.java:47: error: ')' expected
System.out.println("Looking at the numbers you gave me, it seems that you are underweight :/, in fact with a bmi of "bmi",your weight is below that of an average girl. Not having considered your age, there is no way I can tell you wether the condition is critical or not, but you should really consider gaining some weight.");
^
JavaTutorial.java:47: error: not a statement
System.out.println("Looking at the numbers you gave me, it seems that you are underweight :/, in fact with a bmi of "bmi",your weight is below that of an average girl. Not having considered your age, there is no way I can tell you wether the condition is critical or not, but you should really consider gaining some weight.");
^
JavaTutorial.java:47: error: ';' expected
System.out.println("Looking at the numbers you gave me, it seems that you are underweight :/, in fact with a bmi of "bmi",your weight is below that of an average girl. Not having considered your age, there is no way I can tell you wether the condition is critical or not, but you should really consider gaining some weight.");
^
JavaTutorial.java:51: error: ')' expected
System.out.println("Damn giiiirl, you rock! Having a BMI of "bmi", you are an ideal specimen of a healthy female figure. Keep it up!);
^
JavaTutorial.java:51: error: unclosed string literal
System.out.println("Damn giiiirl, you rock! Having a BMI of "bmi", you are an ideal specimen of a healthy female figure. Keep it up!); ^ JavaTutorial.java:51: error: ';' expected
System.out.println("Damn giiiirl, you rock! Having a BMI of "bmi", you are an ideal specimen of a healthy female figure. Keep it up!); ^ JavaTutorial.java:55: error: ')' expected
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.);
^
JavaTutorial.java:55: error: unclosed string literal
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.); ^ JavaTutorial.java:55: error: ';' expected
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.); ^ JavaTutorial.java:59: error: ')' expected
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.); ^ JavaTutorial.java:59: error: unclosed string literal
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.); ^ JavaTutorial.java:59: error: ';' expected
System.out.println("First of all, let me say it's not critical, but with a BMI of "bmi", you are considered overweight, try working out or going for a run from time to time, it sure will help your health.);
^
JavaTutorial.java:62: error: not a statement
else if (bmi > 30) then {
^
JavaTutorial.java:62: error: ';' expected
else if (bmi > 30) then { ^ JavaTutorial.java:62: error: 'else' without 'if'
else if (bmi > 30) then { ^
JavaTutorial.java:63: error: ')' expected
System.out.println("I am so sorry to be the one to inform you, but with a BMI of "bmi",you are consiered obese by the National Health Orgnaization, at this point, your weight might be seriously affecting your health, and I strongly suggest you to take on a diet, start working out or if the case is extreme, seek professional help. Do it for yourself, I believe in you! <3"); ^ JavaTutorial.java:63: error: not a statement
System.out.println("I am so sorry to be the one to inform you, but with a BMI of "bmi",you are consiered obese by the National Health Orgnaization, at this point, your weight might be seriously affecting your health, and I strongly suggest you to take on a diet, start working out or if the case is extreme, seek professional help. Do it for yourself, I believe in you! <3");
^
JavaTutorial.java:63: error: ';' expected
System.out.println("I am so sorry to be the one to inform you, but with a BMI of "bmi",you are consiered obese by the National Health Orgnaization, at this point, your weight might be seriously affecting your health, and I strongly suggest you to take on a diet, start working out or if the case is extreme, seek professional help. Do it for yourself, I believe in you! <3"); ^ JavaTutorial.java:58: error: 'else' without 'if'
else if (bmi > 25 && sex = "boy") {
^
JavaTutorial.java:54: error: 'else' without 'if'
else if (bmi > 25 && sex = "girl") {
^
JavaTutorial.java:46: error: reached end of file while parsing
else if (bmi <= 18.5 && sex = "girl") {
^
JavaTutorial.java:72: error: reached end of file while parsing
}
^
28 errors