To write a program in JavaScript for displaying the result of a student.
Open notepad and type the HTML code.
Define a function to generate the result grade.
Using branching statements analyze the grade achieved.
Open the file in a browser and verify the output.
<html>
<head>
<title>Javascript program to display result of a student</title>
<script type="text/javascript">
function student()
{
var mark1,mark2,mark3,total,percentage;
mark1=parseInt(prompt("Enter Subject-1 Marks"))
mark2=parseInt(prompt("Enter Subject-2 Marks"))
mark3=parseInt(prompt("Enter Subject-3 Marks"))
mark4=parseInt(prompt("Enter Subject-4 Marks"))
mark5=parseInt(prompt("Enter Subject-5 Marks"))
total=mark1+mark2+mark3+mark4+mark5
percentage=total/5;
if((percentage>=91)&&(percentage<=100))
{
alert("O Grade");
}
else if((percentage>=81)&&(percentage<=90))
{
alert("A+ Grade");
}
else if((percentage>=71)&&(percentage<=80))
{
alert("A Grade");
}
else if((percentage>=61)&&(percentage<=70))
{
alert("B+ Grade");
}
else if((percentage>=51)&&(percentage<=60))
{
alert("B Grade");
}
else
{
alert("No Grade");
}
}
</script>
</head>
<body>
<h1 onclick="student()">
Click here to Find Grade Result of a Student
</h1>
</body>
</html>
Student result using JavaScript is created successfully.