<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>分數等級</title>
</head>html
<body>
<script>
//建立變量B,並將用戶輸入的成績賦值給B,再將B/10向下取整從新賦值給B;
var b = prompt("請輸入成績");
while(b<0||b>100){
var b = prompt("成績不合法,請從新輸入成績");
}
var b =Math.floor(b/10);
//當B結果爲6-10時,輸出A-D級,其他輸出E級;
switch(b){
case 10:
document.write("A級");
break;
case 9:
document.write("A級");
break;
case 8:
document.write("B級");
break;
case 7:
document.write("C級");
break;
case 6:
document.write("D級");
break;
default:
document.write("E級");
break;
}
</script>
</body>
</html>ui