Java Tutorial

 
 
 
 
----------------------------------------------------------------------------------
                    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.*;

public class Student extends HttpServlet
{
       public void 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[]=new double[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++;
                 }
                        else if(p[i-1]>=60.0)    
                 {
                out.write(\"Student \"+i+\" : Second Class\");
                second++;
                 } 
            else if(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();
        }
}    

    Related Post:
  1. Program to show the use of Logical or Boolean Negation i.e. NOT (!)

  2. Program of inventory management and demonstrating interactive input and output

  3. Program to show the comparing of Strings for equality

  4. Program to display following things on the client machine a)date and time of the server machine b)date and time of the client machine and difference

  5. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  6. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  7. An applet program that display blinking rectangle

  8. Program to declare, initialize and print a StringBuffer object

  9. Corba program of reverse string

  10. Program using Switch case to compute the net amount to be paid by a customer

  11. Program to show an example of using a recursive method in a class

  12. Program to evaluate following investment equation V=P(1+R)^N

  13. Program to show the use of Bitwise Operator (&) AND

  14. Program to show the use of Nested Loops

  15. Program of FTP client and server

  16. Program to show the use of Conditional OR Operator (||) in If Statements

  17. Program to show the use of Conditional (Ternary) Operator

  18. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  19. Program to show an example of extraction of characters from a StringBuffer objects

  20. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks