上代码
import java.util.Scanner;
public class yunsuan {
public static void main (String [] args) {
System.out.println("*********************");
Scanner tall=new Scanner(System.in);
Scanner weight=new Scanner(System.in);
System.out.println("& 请输入您的体重/kg:");
float a=tall.nextFloat();
System.out.println("& 请输入您的身高/m: ");
float b=tall.nextFloat();
float BMI=sumBMI(a,b);
System.out.println("你的BMI为:"+BMI);
if(BMI<18.5) {
System.out.println("体重过轻");
}else if(BMI<24) {
System.out.println("体重正常");
}else if(BMI<27) {
System.out.println("体重过重");
}else if(BMI<30) {
System.out.println("轻度肥胖");
}else if(BMI<35) {
System.out.println("中度肥胖");
}else {
System.out.println("重度肥胖");
}
System.out.println("*********************");
}
public static float sumBMI(float a, float b) {
final float bmi;
bmi=a/(b*b);
return bmi;
}
}