Discuss / Java / ans

锋清扬__

#1 Created at ... [Delete] [Delete and Lock User]

public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Height (m): ");

double height = scanner.nextDouble();

System.out.print("Weight (kg): ");

double weight = scanner.nextDouble();

// FIXME:

double bmi = weight/(height*height);

// TODO: 打印BMI值及结果

System.out.printf("Your BMI is %.2f\n",bmi);

if (bmi<18.5)

System.out.println("你的BMI结果是过轻");

else if(bmi>=18.5&&bmi<25)

System.out.println("你的BMI结果是正常");

else if(bmi>=25&&bmi<28)

System.out.println("你的BMI结果是过重");

else if(bmi>=28&&bmi<=32)

System.out.println("你的BMI结果是肥胖");

else

System.out.println("你的BMI结果是非常肥胖");

}

}


  • 1

Reply