Discuss / Java / 13

一生为你

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

import java.util.Scanner;

public class Main{

public static void main(String[] args){

Scanner scanner=new Scanner(System.in);

System.out.println("请输入你的体重(单位KG):");

double weight=scanner.nextDouble();

System.out.println("请输入你的身高(单位M):");

double height=scanner.nextDouble();

double BMI=weight/(height*height);

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

        if(BMI<18.5){

System.out.println("过轻");

}

else if(BMI<25){

System.out.println("正常");

}

else if(BMI<28){

System.out.println("过重");

}

else if(BMI<32){

System.out.println("肥胖");

}

else {

System.out.println("非常肥胖");

}

}

}


  • 1

Reply