/**
* 医疗应用程序:计算BMI。
* 身体质量指数 = (体重 / 身高) ^ 2。
* BMI = (weight / height) ^ 2。
* 一磅(pound)等于0.45359237千克(kilogram)。
* 一英寸(inch)等于0.0254米(meter)。
* 提示用户输入体(以磅为单位)重以及身高(以英寸为单位):
* 显示BMI。
* 下面是一个运行示例:
* ————————————————————————————————
* | Enter weight in pounds: 95.5 |
* | Enter height in inches: 50 |
* | BMI is 26.8573 |
* ————————————————————————————————
*/
package Test;
import java.util.Scanner;
public class T214Scanner {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter weight in pounds: ");
double pounds = input.nextDouble();
System.out.print("Enter height in inches: ");
double inches = input.nextDouble();
double kilograms = pounds * 0.45359237;
double meters = inches * 0.0254;
double BMI = kilograms / Math.pow(meters, 2);
System.out.println("BMI is " + BMI);
}
}
第2章:医疗应用程序:计算BMI
最新推荐文章于 2021-09-20 14:02:56 发布