ウェブ学のすすめ

Study of Web Design & Programing

標準体重計算プログラム ver 2.0|男女別

プレビュー
PC版

標準体重計算プログラム ver 2.0|男女別 - jsdo.it - share JavaScript, HTML5 and CSS


スマホ版
標準体重計算プログラム ver 2.0|男女別 - js do it
コード

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>標準体重</title>
</head>
<body>
<script type="text/javascript">
var height;
var weight;
var man;

man = confirm("あなたは男性ですか?");

height = prompt("身長を入力してください。",180);

height = parseInt(height);

if(man){
	weight = (height - 80) * 0.7;
}
else {
	weight = (height - 70) * 0.8;
}

document.write("<h1>");
document.write("身長が",height,"cmの");

if(man){
	document.write("男性の標準体重は");
}
else {
	document.write("女性の標準体重は");
}

document.write(weight,"kgです。");
document.write("<\/h1>");
</script>
</body>
</html>