码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-04-01 20:55:57      阅读:666      评论:0      收藏:0      [点我收藏+]

标签:weight   BMI   height   

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("过胖");

}

}

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

标签:weight   BMI   height   

原文地址:http://blog.51cto.com/13670741/2093598

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!