Js Sop 6
Js Sop 6
Range Grade
35 to 60 F
61 to 70 D
71 to 80 C
81 to 90 B
91 to 100 A
<html>
<title>Javascript program</title>
<head>
<script type="text/javascript">
function calculate_grade(){
var m1,m2,m3,m4,m5,m6,avg;
m1=parseInt(form1.txt_eng.value);
m2=parseInt(form1.txt_phy.value);
m3=parseInt(form1.txt_chem.value);
m4=parseInt(form1.txt_it.value);
m5=parseInt(form1.txt_maths.value);
m6=parseInt(form1.txt_bio.value);
avg=(m1+m2+m3+m4+m5+m6)/6;
alert("Average marks of students for six subjects is:"+ avg);
if(avg>=91 && avg<=100)
{
grade = 'A';
}
else if(avg>=81 && avg<=90)
{
grade = 'B';
}
else if(avg>=71 && avg<=80)
{
grade = 'C';
}
else if(avg>=61 && avg<=70)
{
grade = 'D';
}
else if (avg>=35 && avg<=60)
{
grade = 'F';
}
alert ("Grade of the student is: "+ grade);
}
</script>
</head>
<body bgcolor="pink">
<form name="form1" method="post">
<p><h1>Enter Marks of subjects of students</h1><br><br>
English <input type="text" name="txt_eng"><br><br>
Physics <input type="text" name="txt_phy"><br><br>
Chemistry <input type="text" name="txt_chem"><br><br>
IT <input type="text" name="txt_it"><br><br>
Maths <input type="text" name="txt_maths"><br><br>
Biology <input type="text" name="txt_bio"><br><br>
<input type="submit" value="Calculate Average & print grade"
onclick="calculate_grade()">
</form>
</body>
</html>