我在這個已經持續了一個星期,似乎無法弄清楚..顯示比例和缺勤
的程序要求用戶輸入缺席他們的數量和它們的等級,但如果學生缺勤5次或更多,則無論其百分比如何,都會自動失敗。
- A級 - 90〜100
- B級 - 80〜89.9
- C級 - 70〜79.9
- 等級d 60〜69.9
- 低於60任何一個是F.
這裏是我到目前爲止的代碼:
<html>
<head>
</head>
<body>
<script type="text/javascript">
//Program Name: gradeReporter.html
//Author:
//Date: November 5th 2015
//Purpose: Calculate grades and absences of students
//Variables
var percent = parseInt(percent * 1.03);
var absences = parseInt(absences);
var ES = ""; // Empty string
var PA = "<p />"; // HTML paragraph break
var BR = "<br />" \t // HTML line break
//Start the program
if (absences >= 5) {
document.write("You have failed due to having more than 5 absences");
if (percent <= 100 || percent >= 90 && absences <=2) {
document.write("Your Grade: A. Your percent: " * percent);
}
else if (percent <= 89.9 || percent >= 80 && absences <=2) {
document.write("Your Grade: B. Your percent: " * percent);
}
else if (percent <= 79.9 || percent >= 70 && absences <=2) {
document.write("Your Grade: C. Your percentage: " * percent);
}
else if (percent <= 69.9 || percent >= 60 && absences <=2) {
document.write("Your Grade: D. Your percentage: " * percent);
}
else if (percent <= 59.9 || percent >= 50 && absences <=2) {
document.write("Grade: F. You have failed this semester.");
}
}
</script>
</body>
</html>
問題是什麼? – isherwood
另外,'document.write'是一種過時的技術。改爲使用DOM插入('innerHTML')。 – isherwood
目前還不清楚你在做什麼,這個問題看起來像是一個非常基本的if/else編程練習,你是想用Javascript/HTML/CSS來複制問題的行爲嗎? – AGE