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 Concat Strings

  2. An applet program to display moving banner

  3. Socket program of HTTP Server

  4. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

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

  6. An applet program that displays random dot

  7. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  8. Corba program of game

  9. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  10. Write a class whose objects holds a current value and have a method to add that value, printing the new value

  11. An applet program that display blinking rectangle

  12. An applet program to display alternate filled and empty circle that to in row and column format

  13. RMI application for getting the final total price of the shopping list with some of the following items and quantities chosen by the user

  14. RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct

  15. Program of writing Bytes to a File

  16. Add,delete,Update in LISTS

  17. Program to show the use of Increment and Decrement Operators

  18. Program to declare, initialize and print an array of characters

  19. Program that will read real number from the keyboard and print the following output in one line: small Integer not less The Given Number Largest Int

  20. Program to show the use of While Loop