计算身体质量指数

来源:互联网 发布:linux文件管理web 编辑:程序博客网 时间:2024/04/30 20:41
import java.util.Scanner;public class ComputeAndInterpretBMI {public static void main(String [] args){Scanner input = new Scanner(System.in);System.out.print("Enter weight in pounds:");double weight = input.nextDouble();System.out.print("Enter height in inches: ");double height = input.nextDouble();input.close();final double KILOGRAMS_PER_POUND = 0.45359237;final double METERS_PER_INCH = 0.0254;double weightInKilograms = weight * KILOGRAMS_PER_POUND;double heightInMeters = height * METERS_PER_INCH;double bmi = weightInKilograms / (heightInMeters * heightInMeters);System.out.println("Your BMI is " + bmi);if(bmi < 16)System.out.println("You are seriously underweight");else if(bmi < 18)System.out.println("You are underweight");else if(bmi < 24)System.out.println("You are normal");else if(bmi < 29)System.out.println("You are overweight");else if(bmi < 35)System.out.println("You are gravely overweigth");}}

0 0
原创粉丝点击