请问这样写可以的吗?
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>练习</title>
</head>
<body>
<script type="text/javascript">
var sex=prompt('请输入性别');
var height = Number(prompt('请输入身高'));
var weight = Number(prompt('请输入体重'));
var weightm=(weight-80)*0.7;
var weightw = (weight - 70) * 0.6;
if (sex=='男') {
if (weight>weightm*0.05 && weight<weightm*1.05) {
alert('体重正常');
}else if (weight < weightm * 0.05) {
alert('太瘦了,要多补充营养哦');
}else{
alert('该锻炼身体减肥了哦');
}
}else if (weight > weightw * 0.05 && weight < weightw * 1.05) {
alert('体重正常');
} else if (weight < weightw * 0.05) {
alert('太瘦了,要多补充营养哦');
} else {
alert('该锻炼身体减肥了哦');
}
</script>
</body>
</html>
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星