Practical-18 Develop a JSP program to display the grade of a student by accepting the marks of five subjects.
index.html:
<!DOCTYPE html>
<html>
<head>
<title>Enter Marks</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>Enter Marks</p>
<form action="result.jsp" method="get">
Enter AJP Marks : <input type="text" name="ajp"> <br><br>
Enter NMA Marks : <input type="text" name="nma"><br><br>
Enter MCAD Marks : <input type="text" name="mcad"><br><br>
Enter PPUD Marks : <input type="text" name="ppud"><br><br>
Enter Project Marks : <input type="text" name="proj"><br><br>
<input type="submit">
</form>
</body>
</html>
<html>
<head>
<title>Enter Marks</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>Enter Marks</p>
<form action="result.jsp" method="get">
Enter AJP Marks : <input type="text" name="ajp"> <br><br>
Enter NMA Marks : <input type="text" name="nma"><br><br>
Enter MCAD Marks : <input type="text" name="mcad"><br><br>
Enter PPUD Marks : <input type="text" name="ppud"><br><br>
Enter Project Marks : <input type="text" name="proj"><br><br>
<input type="submit">
</form>
</body>
</html>
result.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Result Page</title>
</head>
<body>
<%
int AJP=Integer.parseInt(request.getParameter("ajp"));
int NMA=Integer.parseInt(request.getParameter("nma"));
int MCAD=Integer.parseInt(request.getParameter("mcad"));
int PPUD=Integer.parseInt(request.getParameter("ppud"));
int Project=Integer.parseInt(request.getParameter("proj"));
int c=AJP+NMA+MCAD+PPUD+Project;
double avg=c/5;
out.print("Your grade is ");
if(avg > 90 ){
out.print("A");
}else if (avg >= 80) {
out.print("B");
} else if (avg >= 70) {
out.print("C");
} else if (avg >= 60) {
out.print("D");
} else {
out.print("E");
}
%>
</body>
</html>
Output:
Comments
Post a Comment