function avgScore(n,m,f)
{
var a = n * 0.3 + m * 0.3 + f * 0.4;
return a;
}
function ScoreLevel(avg)
{
if (90 <= avg) {
level = 'A';
}
else if (80 <= avg && avg <= 89) {
level = 'B';
}
else if (70 <= avg && avg<= 79) {
level = 'C';
}
else if (60 <= avg && avg<= 69) {
level = 'D';
}
else if (avg < 60) {
level = 'F';
}
return level;
}
do
{
var name = prompt("請輸入你的姓名", "")
var nScore = prompt("請輸入你的平時分數", "")
var mScore = prompt("請輸入你的期中分數", "")
var fScore = prompt("請輸入你的期末分數", "")
var avg = avgScore(nScore, mScore, fScore);
var level = ScoreLevel(avg)
var YorN = prompt("是否繼續(Y/N)?", "")
var Students = new Array(1);
for (var i = 0; i < Students.length; i++)
Students[i] = new Array(6);
Students[0][0] = " " + name;
Students[0][1] = " " + nScore;
Students[0][2] = " " + mScore;
Students[0][3] = " " + fScore;
Students[0][4] = " " + avg;
Students[0][5] = " " + level;
for (var i = 0; i < Students.length; i++)
{
document.write("<tr>");
for (var j = 0; j < Students[i].length; j++)
document.write("<td>" + Students[i][j] + "</td>");
document.write("</tr>");
}
}while ( YorN == 'Y')