
I cant figure out what I am doing wrong in my code can anyone help me out???
Computing your grade for a class.

Hi Friend,
Try the following code:
<html>
<head>
<title> Grades </title>
<script type="text/javascript">
function computeGrade( )
{
var hw, lab, midt, fin, avg;
hw = parseFloat(document.grade.txthw.value);
lab = parseFloat(document.grade.txtlab.value);
midt = parseFloat(document.grade.txtmidt.value);
fin = parseFloat(document.grade.txtfin.value);
avg = hw*0.25 + lab*0.20 + midt*0.25 + fin*0.30 ;
document.grade.txtAV.value = avg;
var r = parseFloat(avg);
if (r >= 90)
document.grade.txtResult.value = " A ";
else if (r <= 89 || r >= 80)
document.grade.txtResult.value = " B ";
else if (r <= 79 || r >=70)
document.grade.txtResult.value = " C ";
else if (r <= 69 || r >=60)
document.grade.txtResult.value = " D ";
}
</script>
</head> </p>
<body> </p>
<h2>Class Average Calculator</h1> </p>
Computing your grade for a class. </p>
<form name="grade">
<table>
<tr>
<td>Homework</td>
<td><input type="text" name="txthw" size="10"
value="" /></td>
</tr>
<tr>
<td>Labs</td>
<td><input type="text" name="txtlab" size="10"
value="" /></td>
</tr>
<tr>
<td>Midterm</td>
<td><input type="text" name="txtmidt" size="10"
value="" /></td>
</tr>
<tr>
<td>Finals</td>
<td><input type="text" name="txtfin" size="10"
value="" /></td>
</tr>
<tr>
<td>Your Average</td>
<td><input type="text" name="txtAV" size="10"
value="" /></td>
</tr>
</table>
<input type="button" name="btnComputeGrade" value="Compute Class Average" onclick="computeGrade();" />
<input name="txtResult" size="36" type="text"> </p>
</form>
</body>
</html>
Thanks

Thank you i eventually figured out i had the signs reversed :/
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.