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

本文介绍了一款使用Java编写的程序,该程序能够帮助用户计算其身体质量指数(BMI)。用户只需输入体重(以磅为单位)和身高(以英寸为单位),程序将自动转换单位并计算BMI值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值