0% found this document useful (0 votes)
6 views4 pages

JavaScript Practical No 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

JavaScript Practical No 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript Practical No - 4

<!DOCTYPE html>
<html>
<head>
<title>Program to compute the average</title>
<script>
function calculateAverage() {
var grade;
var marathi =
parseFloat(document.getElementById('mar').value);
var hindi = parseFloat(document.getElementById('hin').value);
var english = parseFloat(document.getElementById('eng').value);
var maths =
parseFloat(document.getElementById('maths').value);
var history = parseFloat(document.getElementById('his').value);
var geography =
parseFloat(document.getElementById('geo').value);
var avg = (marathi + hindi + english + maths + history +
geography) / 6;
document.getElementById('result').innerHTML= "Your average of
marks is " + avg;
if(avg>=35 && avg<=60){
grade = 'F';
}
else if(avg>=61 && avg<=70){
grade = 'D';
}
else if(avg>=71 && avg<=80){
grade = 'C';
}
else if(avg>=81 && avg<=90){
grade = 'B';
}
else if(avg>=91 && avg<=100){
grade = 'A';
}
else{
grade = "FAILED!!"
}
document.getElementById("grade").innerHTML = "Your Grade is
: " + grade;
}
</script>
</head>
<body>
<h2>Enter your Marks </h2>
<form name="form1">
Marathi : <input type="text" id="mar" name="s1"><br><br>
Hindi : <input type="text" id="hin" name="s2"><br><br>
English : <input type="text" id="eng" name="s3"><br><br>
Maths : <input type="text" id="maths" name="s4"><br><br>
History : <input type="text" id="his" name="s5"><br><br>
Geography : <input type="text" id="geo" name="s6"><br><br>
<input type="button" value="Check Result"
onclick="calculateAverage()">
</form>
<p id="result"></p>
<p id="grade"></p>
</body>
</html>
Output:

You might also like