BMI
本帖最后由 cho 于 2014-6-18 10:13 编辑import java.util.Scanner;
//新建一个类BMI
public class BMI {
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 inchs:"); //输入体重
double height = input.nextDouble();
final double KILOGRAMS_PER_POUND = 0.45359237; //设置常量
final double METERS_PRE_INCH = 0.0254;
double weightInKilograms = weight * KILOGRAMS_PER_POUND;
double heightInMeters = height * METERS_PRE_INCH;
double bmi = weightInKilograms / heightInMeters * heightInMeters; //计算BMI
System.out.println("You bmi is" + bmi); //输出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 weight");
else if (bmi < 29 )
System.out.println("You are overweight");
else if (bmi < 35 )
System.out.println("You are seriously overweight");
else
System.out.println("You are gravely overweight");
}
} 2013年9月28日12:30-14:00这个时间好神奇啊
一般的会议都不搞在午休时间吧:o 2013年9月28日12:30-14:00
这个时间好神奇啊
第一次看到这个时间开会的 zhoujmao 发表于 2013-9-25 16:59
2013年9月28日12:30-14:00
这个时间好神奇啊
第一次看到这个时间开会的
import java.util.Scanner;
//新建一个类BMI
public class BMI {
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 inchs:"); //输入体重
double height = input.nextDouble();
final double KILOGRAMS_PER_POUND = 0.45359237; //设置常量
final double METERS_PRE_INCH = 0.0254;
double weightInKilograms = weight * KILOGRAMS_PER_POUND;
double heightInMeters = height * METERS_PRE_INCH;
double bmi = weightInKilograms / heightInMeters * heightInMeters; //计算BMI
System.out.println("You bmi is" + bmi); //输出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 weight");
else if (bmi < 29 )
System.out.println("You are overweight");
else if (bmi < 35 )
System.out.println("You are seriously overweight");
else
System.out.println("You are gravely overweight");
}
}
页:
[1]