Today & Tomorrow...

勝手気ままな、備忘録的な感じです。

【javascript】

javascript

標準体重プログラム

<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>標準体重</title>
</head>

<body>
<script type="text/javascript">



<!--
/*
*標準体重計算プログラム
*最終修整日:2012.06.11
*/

var height;//身長
var weight;//体重
var man; //男性かどうか

//男性か女性かを入力
man = confirm("あなたは男性ですか?"); 

//身長を入力する
height=prompt("身長を入力してください", 170);
height = parseInt(height);
//計算を行う

// 計算を行う
if (man) {
	weight = (height -80) * 0.7;
} else {
	weight = (height -70) * 0.6;
}



//結果を表示する

document.write("<h1>");
document.write("身長が", height, "cmの");
if (man) {
	document.write("男性の標準体重は");
} else {
	document.write("女性の標準体重は");
}

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

//-->


</script>
</body>
</html>