i'm trying to make a bmi calculator but the answer keeps being the same.
i tried putting numbers height=1.50 meter weight=100 kg
but the answer was underweigth
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double bmi = 0;
double weightinkg = 0;
double heightinmeter = 0;
String status = "";
System.out.println("Enter the weight in Kg :");
weightinkg = sc.nextDouble();
System.out.println("Enter the height in Meter : "); //enter the age
heightinmeter = sc.nextDouble();
if ((weightinkg <= 0) && (heightinmeter <= 0))
System.out.println("ERROR: Negative number");
double square = Math.pow(heightinmeter, 2);
bmi = weightinkg / heightinmeter;
if (bmi >= 0) {
if (bmi >= 0 && bmi <= 24) {
status = "Under Weight";
} else if (bmi >= 25 && bmi <= 29) {
status = "Healthy";
} else if (bmi >= 30 && bmi <= 34) {
status = "Overweight";
} else
status = "Obese";
}
else
System.out.println("Invalid BMI (number must be positive");
System.out.printf("Hello, your status is %s ! Please come again!", status);
}
question from:
https://stackoverflow.com/questions/65936771/my-java-bmi-calculator-giving-the-same-answer 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…