您的位置:首页 > 编程语言 > Java开发

java语言程序设计(基础篇)第十版编程练习题[2.14]

2019-01-06 08:20 197 查看

(医疗应用程序:计算 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);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: