package package2; import java.util.Scanner; public class Hello13 { private static double bmi; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("请输入您的体重(kg):"); int weight = scanner.nextInt(); System.out.println("请输入您的身高(m):"); double high = scanner.nextDouble(); bmi = weight / (high * high); if (bmi >= 32) { show("非常肥胖!"); } else if (bmi >= 28) { show("肥胖!"); } else if (bmi >= 25) { show("过重!"); } else if (bmi >= 18.5) { show("正常!"); } else { show("过轻!"); } scanner.close();// 释放资源 } public static void show(String msg) { System.out.printf("你的体质指数BMI是:%.2f", bmi); System.out.println(); System.out.println(msg); } }
Sign in to make a reply
永夜闲阶