Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » CorbaRSS Feeds

Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

Posted By: Ashton Evans     Category: Java     Views: 10518

Write a RMI based Pass the marks of 10 students from the client side. Design a servlet, which takes these marks and returns the number of students
who obtained first class, second-class and pass class.

Code for Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls in Java

----------------------------------------------------------------------------------
                    HTML File
----------------------------------------------------------------------------------
<html>
<head Student Details>
<title Student Details>
</title>
</head>

<body>
<form name="form1" method="GET" action="/q1/try1.do">
<BR><h1>Student Marks</h1><br>

Enter Marks for Student 1:
<input type=text name=stud1>
<br><br>

Enter Marks for Student 2:
<input type=text name=stud2>
<br><br>

Enter Marks for Student 3:
<input type=text name=stud3>
<br><br>

Enter Marks for Student 4:
<input type=text name=stud4>
<br><br>

Enter Marks for Student 5:
<input type=text name=stud5>
<br><br>

Enter Marks for Student 6:
<input type=text name=stud6>
<br><br>

Enter Marks for Student 7:
<input type=text name=stud7>
<br><br>

Enter Marks for Student 8:
<input type=text name=stud8>
<br><br>

Enter Marks for Student 9:
<input type=text name=stud9>
<br><br>

Enter Marks for Student 10:
<input type=text name=stud10>
<br><br>

<input type=submit value=SUBMIT>
</form>
</body>
</html>

-------------------------------------------------------------------------------------------------
                    Java File
-------------------------------------------------------------------------------------------------

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

publicclass Student extends HttpServlet
{
       publicvoid doGet(HttpServletRequest req, HttpServletResponse res) throws 
       IOException, ServletException
       {
                   PrintWriter out=res.getWriter();
                   int s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
                   double p[]=newdouble[10];
                   int first=0, second=0, third=0;    
                   out.write("<html>");
                   out.write("<head>");
                   out.write("<title>");
                   out.write("</title>");
                   out.write("<body>");
                   out.write("<h1>Results</h1><br><br>");

                   s1=Integer.parseInt(req.getParameter("stud1"));
                   p[0]=((100*s1)/400);
    
                   s2=Integer.parseInt(req.getParameter("stud2"));
                   p[1]=((100*s2)/400);

                   s3=Integer.parseInt(req.getParameter("stud3"));
                   p[2]=((100*s3)/400);

                   s4=Integer.parseInt(req.getParameter("stud4"));
                   p[3]=((100*s4)/400);

                   s5=Integer.parseInt(req.getParameter("stud5"));
                   p[4]=((100*s5)/400);

                   s6=Integer.parseInt(req.getParameter("stud6"));
                   p[5]=((100*s6)/400);

                   s7=Integer.parseInt(req.getParameter("stud7"));
                   p[6]=((100*s7)/400);

                   s8=Integer.parseInt(req.getParameter("stud8"));
                   p[7]=((100*s8)/400);

                   s9=Integer.parseInt(req.getParameter("stud9"));
                   p[8]=((100*s9)/400);
    
                   s10=Integer.parseInt(req.getParameter("stud10"));
                   p[9]=((100*s10)/400);

                   for(int i=0; i<10; i++)
                   {
                    if(p[i-1]>=70.0)    
                   {
                out.write("Student "+i+" : First Class");
                first++;
                 }
                        elseif(p[i-1]>=60.0)    
                 {
                out.write("Student "+i+" : Second Class");
                second++;
                 } 
            elseif(p[i-1]>=45.0)    
                 {
                out.write("Student "+i+" : Third Class");
                third++;
                 }
                 out.write("<br><br>");
                }    
    
                out.write("<br><br>");
                out.write("Total of First Class :" + first);
                
                out.write("<br><br>");
                out.write("Total of Second Class :" + second);
                
                out.write("<br><br>");
                out.write("Total of Third Class :" + third);

                out.write("</body>");
                out.write("</html>");
        
                out.close();
        }
}    
  
Share: 



Ashton Evans
Ashton Evans author of Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!