(医疗应用程序:计算 BMI) 身体质量指数(BMI) 是对体重的健康测量。它的值可以通过将体重(以公斤为单位)除以身高(以米为单位)的平方值得到。编写程序,提示用户输人体重(以磅为单位)以及身髙(以英寸为单位),然后显示 BMI。注意:一磅是 0.4S3S9237公斤,一英
寸是 0.0254 米。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dome2_14;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class Dome2_14 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in = new Scanner(System.in);
System.out.print("Enter weight in pounds: ");
double weight = in.nextDouble();
System.out.print("Enter height in inches: ");
double height = in.nextDouble();
double BMI = (weight * 0.45359237) / Math.pow((height * 0.0254), 2);
System.out.println("BMI is " + BMI);
}
}