Discuss / Java / 重新提交

重新提交

Topic source
import java.util.Scanner;

public class BMI{
	public static void main(String[] args){
	
		Scanner input = new Scanner(System.in);
		System.out.print("输入体重(kg): ");
		double ww = input.nextDouble();
		System.out.print("输入身高(m): ");
		double hh = input.nextDouble();

		double bmi = ww / (Math.pow(hh ,2));

        System.out.printf("BMI: %.2f \n",bmi);
		if (bmi >32) {
			System.out.println("非常肥胖");
		}else if(bmi > 28){
			System.out.println("肥胖");
		}else if(bmi > 25){
			System.out.println("重");
		}else if(bmi>=18.5){
			System.out.println("正常");
		}else{
			System.out.println("轻");
		}
	}
}

  • 1

Reply