代码:(给出BMI的相关注释)
abstract class People{
int weight;
int height;
public People(int w, int h) {
this.weight = w;
this.height = h;
}
abstract public float stature();
public void drawResult() {
System.out.print("体重:"+this.weight+"(KG) 身高:"+this.height+"(cm)");
// BMI
// float statureResult = this.stature();
// if (statureResult<= 18.4) {
// System.out.println("体型:偏瘦");
// }else if (statureResult <= 23.9 && statureResult > 18.4) {
// System.out.println("体型:正常");
// }else if (statureResult < 23.9 && statureResult <= 27.9) {
// System.out.println("体型:超重");
// }else if (statureResult > 27.9) {
// System.out.println("体型:肥胖");
// } else {
// System.out.println("啥,应该不会运行到这里吧?");
// }
float statureResult = this.weight/this.stature()-1;
if(statureResult>=-0.1&&statureResult<=0.1) {
System.out.println("体型:标准");
}else if (statureResult<-0.1) {
System.out.println("体型:偏瘦");
}else if (st

最低0.47元/天 解锁文章
3899

被折叠的 条评论
为什么被折叠?



