Discuss / Java / if 判断练习

if 判断练习

Topic source

陆佩廷

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

public static void main(String args[]) {

double height = 1.68;

double weight = 55;

double MBI = (weight) / (height * height);

if (MBI < 18.5) {

System.out.printf("你的MBI: %s 过轻:低于18.5", MBI);

} else if (MBI >= 18.5 && MBI < 25) {

System.out.printf("你的MBI: %s 正常:18.5-25", MBI);

} else if (MBI >= 25 && MBI < 28) {

System.out.printf("你的MBI: %s 过重:25-28", MBI);

} else if (MBI >= 28 && MBI < 32) {

System.out.printf("你的MBI: %s 肥胖:28-32", MBI);

} else if (MBI >= 32) {

System.out.printf("你的MBI: %s 非常肥胖:高于32", MBI);

}

}


  • 1

Reply