我正在尝试编写一个程序来接收一个数字,并使用 javascript 和 html 将其映射到基于字母等级的标记。
当我运行代码时,我没有得到任何答案。
这是代码:
HTML
<h1>mapping a numerical grade to a letter grade</h1>
</header>
<div class="column1">
<div class="input">
a <input id="number1" type="number" min=" -32768" max=" 32767" />
</div>
<div class="input">
<button onclick="mapping()">enter</button>
</div>
<strong><p id="output"></p></strong>
</div>
Javascript
function mapping() {
var a = parseInt(document.getElementById("number1").value);
switch (true) {
case a > 89:
answer = "A+";
break;
case a > 79:
answer = "A";
break;
case a > 74:
answer = "B+";
break;
case a > 69:
answer = "B";
break;
case a > 64:
answer = "C+";
break;
case a > 59:
answer = "C";
case a > 54:
answer = "D+";
case a > 49:
answer = "D";
break;
case a > 40:
answer = "E";
break;
default:
answer = "F";
document.getElementById("output").innerHTML = answer;
}
慕标5832272
GCT1015
相关分类