So I have no idea what I'm doing wrong, but Im guessing I entered in the formula to calculate the final grade wrong because when I press the calculate button nothing shows up. Im not sure how I'm supposed to enter the formula. Can someone please point me in the right direction? By the way its a grade calculator where you can enter whatever the values are for each category and then at the end it gives you the numerical grade and also the letter grade. Thanks in advance.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Lab</title>
<meta charset="utf-8">
<script>
function calculateGrade ()
{
var test1 = document.getElementById("t1")
var test2 = document.getElementById("t2")
var finalexam = document.getElementById("t3")
var labs = document.getElementById("t4")
var projects = document.getElementById("t5")
var quizzes = document.getElementById("t6")
var grade= document.getElementById("fng")
grade.value=parseFloat(0.15*test1.value)+parseFloat(0.15*test2.value)+parseFloat(0.20*finalexam.valu e)+parseFloat(0.30*labs.value)+
parseFloat(0.05*projects.value)+parseFloat(0.15*quizzes.value)
}
function getLetterGrade(totalGrade)
{
if (totalGrade >= 90)
letterGrade = "A";
else if (totalGrade < 90 && totalGrade >= 80)
letterGrade = "B";
else if (totalGrade < 80 && totalGrade >= 70)
letterGrade = "C";
else if (totalGrade < 70 && totalGrade >= 60)
letterGrade = "D";
else if (totalGrade < 60 && totalGrade > =50)
letterGrade = "F";
}
</script>
</head>
<body>
<form id="form1" name="form1">
<table>
<tr>
<th colspan="2"> Score </th>
</tr>
<tr>
<td> Test 1 </td>
<td><input type="text" name="t1" id="t1" value= ""></td>
</tr>
<tr>
<td> Test 2 </td>
<td><input type="text" name="t2" id="t2" value= ""></td>
</tr>
<tr>
<td> Final Exam </td>
<td><input type="text" name="t3" id="t3" value=""></td>
</tr>
<tr>
<td> Labs </td>
<td><input type="text" name="t4" id="t4" value=""></td>
</tr>
<tr>
<td> Projects </td>
<td><input type="text" name="t5" id="t5" value=""></td>
</tr>
<tr>
<td> Quizzes </td>
<td><input type="text" name="t6" id="t6" value=""></td>
</tr>
<tr>
<th colspan="2">
<input type="button" name="b1" id="b1" value="Calculate Grade"
onclick="calculateGrade()">
</th>
</tr>
<tr>
<td> Final numerical grade </td>
<td><input type="text" name="fng" id="fng" style="border: none"></td>
</tr>
<tr>
<td> Final letter grade </td>
<td><input type="text" name="letterGrade" id="letterGrade" style="border: none"></td>
</tr>
</table>
</form>
</body>
</html>


Reply With Quote

Bookmarks