它的值可以通过将体重(以公斤为单位)除身高(以米为单位)的平方值得到。编写程序,提示用户输入体重(以磅为单位)以及身高(以英寸为单位),然后显示BMI。
注意:一磅是0.45359237公斤,一英寸是0.0254米。
下面是一个运算示例:
Enter weight in pound: 95.5
Enter hight in inches: 50
BIM is 26.8573
package Second;import java.util.Scanner;public class Code14 {public static void main(String[] args) {System.out.print("Enter weight in pound: ");Scanner input = new Scanner(System.in);double weight = input.nextDouble();System.out.print("Enter hight in inches: ");double hight = input.nextDouble();double BIM = 0;BIM = weight * 0.45359237 / (hight * hight * 0.0254 * 0.0254);System.out.println("BIM is " + BIM);}}
输出
Enter weight in pound: 95.5Enter hight in inches: 50BIM is 26.857257942215885
如果觉得《Java *2.14(医疗应用程序:计算BMI)身体质量指数(BMI)是对体重的健康测量。》对你有帮助,请点赞、收藏,并留下你的观点哦!