Я создаю bmi caculator и использую формулу роста и веса.Я продолжаю получать erorr с надписью nan obe в самом конце, и я не знаю, что мне не хватает или что мне нужно отредактировать.Любая помощь будет оценена.
Ошибка вывода:
Enter Weight in pounds: 150
Enter height (ft.):
6
Enter height (in.):
7
Your BMI is: NaN
Obese
Формула ИМТ: BMI = (703 * weightInPounds) / heightInInches^2
Код:
import java.util.Scanner;
public class Bmi_Calc {
public static void main(String[] args) {
// TODO Auto-generated method st
Scanner input = new Scanner(System.in);
//double weight;
double weightInPounds;
int feet;
int inches;
//int weightInPounds;
int heightInInches;
double height;
System.out.print("Enter Weight in pounds: ");
double weight = input.nextDouble();
System.out.println("Enter height (ft.): ");
feet = input.nextInt();
System.out.println("Enter height (in.): ");
inches = input.nextInt();
weightInPounds = 0;
heightInInches = 0;
double bmi = (703 * weightInPounds) / Math.pow(heightInInches, 2.0);
double heightMeters = ((feet * 12) + inches) * .0254;
System.out.println("Your BMI is: " + bmi);
if (bmi < 18.5) {
System.out.println("Underweight.");
}
if ((bmi >= 18.5) && (bmi < 24.9)) {
System.out.println("Normal weight");
}
if ((bmi >= 25) && (bmi < 29.9)) {
System.out.println("Overwight");
}
else {
System.out.println("Obese");
}
input.close();
}
}