这是我的第一个有几种方法的程序
第一个必须将高度转换为英寸
2、计算BMI
第三次接收 BMI 并返回状态
第 4 个是主要的,必须调用输入并生成输出
问题是它不计算 BMI - 它输出 0。当我只用一种方法运行它时,它工作正常。可能出了什么问题?
package bmiCalculator;
java.util.Scanner;
public class BmiCalculator {
public static double bmi;
public static int height;
public static int feet;
public static int inches;
public static int weight;
public static String status;
public static void convertToInches (){
height = feet * 12 + inches;
}
public static void bmiCalculator (){
bmi = (weight * 703) / (height * height);
}
public static void weightStatus () {
if (bmi < 18.5){
status = "underweight";
}
else if (bmi <= 24.9){
status = "normal";
}
else if (bmi <= 29.9){
status = "overweight";
}
else if (bmi >= 30){
status = "obese";
}
}
public static void main (String[] args){
System.out.println("Put your height in ft and inches");
Scanner sc = new Scanner(System.in);
feet = sc.nextInt();
inches = sc.nextInt();
System.out.println("Put your weight in pounds");
weight = sc.nextInt();
System.out.println("Height: " + feet + " feet, " + inches + " inches");
System.out.println("Weight: " + weight + " pounds");
System.out.println("Your BMI is " + bmi + "category" + status);
}
}
Helenr
呼如林
相关分类