?著作權(quán)歸作者所有:來自51CTO博客作者wx63d882c621cf8的原創(chuàng)作品,請聯(lián)系作者獲取轉(zhuǎn)載授權(quán),否則將追究法律責(zé)任
*3.6(健康應(yīng)用:BMI)修改程序清單3-4,讓用戶輸入重量、英尺和英寸。例如一個(gè)人身高是5英尺10英寸,輸入的英尺值就是5、英寸值為10。注意:1英尺=0.3048米。
下面是一個(gè)運(yùn)行示例:
Enter weight in pounds:140
Enter feet:5
Enter inches:10
BMI is 20.087702275404553
*3.6(Health application: BMI) Revise Listing 3.4, ComputeAndInterpretBMI.java, to let the user enter weight, feet, and inches. For example, if a person is 5 feet and 10 inches, you will enter 5 for feet and 10 for inches.
Here is a sample run:
Enter weight in pounds:140
Enter feet:5
Enter inches:10
BMI is 20.087702275404553
下面是參考答案代碼:
運(yùn)行效果:
注:編寫程序要養(yǎng)成良好習(xí)慣
如:1.文件名要用英文,具體一點(diǎn)
2.注釋要英文
3.變量命名要具體,不要抽象(如:a,b,c等等),形式要駝峰化
4.整體書寫風(fēng)格要統(tǒng)一(不要這里是駝峰,那里是下劃線,這里的邏輯段落空三行,那里相同的邏輯段落空5行等等)
相關(guān)文章