首页 > 试题广场 >

(医疗应用程序:计算 BMI) 身体质量指数(BMI) 是

[问答题]
 (医疗应用程序:计算 BMI) 身体质量指数(BMI) 是对体重的健康测量。它的值可以通过将体 重(以公斤为单位)除以身高(以米为单位)的平方值得到。编写程序,提示用户输人体重(以 磅为单位)以及身髙(以英寸为单位),然后显示 BMI。注意:一磅是 0.4S3S9237公斤,一英 寸是 0.0254 米。下面是一个运行示例: 

package AA;
import java.util.Scanner;
public class ah {
    public static void main(String[] args){
              double weight,height,pounds,inches;
              System.out.print("Enter weight in pounds:");
              Scanner in=new Scanner(System.in);
              pounds=in.nextDouble();
              System.out.print("Enter height in inches:");
              Scanner s=new Scanner(System.in);
              inches=s.nextDouble();
              double BMI=0;
              weight=pounds*0.45359237;
              height=inches*0.0254;
              BMI=weight/Math.pow(height,2);
              System.out.print("BMI is"+String.format("%.4f",BMI));
              
    }

}
发表于 2021-04-06 15:32:33 回复(0)