继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

java程序:计算身体质量指数

慕粉0415482673
关注TA
已关注
手记 297
粉丝 64
获赞 367

import java.util.Scanner;
public class WeightOfBmi {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("enter a number for weight: ");
double weight = input.nextDouble();
System.out.println("enter a number for height: ");
double height = input.nextDouble();
final double KILOGRAMS_PER_POUND=0.45359237;
final double METERS_PER_INCH=0.0254;
double weightInKilogram = weightKILOGRAMS_PER_POUND;
double heightInMeters = height
METERS_PER_INCH;
double bmi = weightInKilogram/(heightInMeters*heightInMeters);
System.out.println("BMI is : "+bmi);
if(bmi<18.5)
System.out.println("偏瘦");
else if(bmi<25)
System.out.println("正常");
else if(bmi<30)
System.out.println("超重");
else
System.out.println("过胖");

}

}

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP