You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
829 B
27 lines
829 B
import java.util.Scanner;
|
|
public class BMICalculator {
|
|
public static void main(String[] args) {
|
|
Scanner scanner = new Scanner(System.in);
|
|
|
|
System.out.print("请输入身高(米):");
|
|
double height = scanner.nextDouble();
|
|
|
|
System.out.print("请输入体重(千克):");
|
|
double weight = scanner.nextDouble();
|
|
|
|
double bmi = weight / (height * height);
|
|
System.out.printf("你的 BMI 值为:%.2f%n", bmi);
|
|
|
|
// BMI 范围判断
|
|
if (bmi < 18.5) {
|
|
System.out.println("体重过轻");
|
|
} else if (bmi < 24) {
|
|
System.out.println("正常范围");
|
|
} else if (bmi < 28) {
|
|
System.out.println("超重");
|
|
} else {
|
|
System.out.println("肥胖");
|
|
}
|
|
scanner.close();
|
|
}
|
|
}
|