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. Encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time after each word in the sent

  2. Program to show an example of Multiple Levels of Inheritance

  3. Program to declare, initialize and print a 2D array of integers

  4. Program that accepts a shopping list of five items from the command line and stores them in vector

  5. Program to generate Fibonacci Series of a given number

  6. An applet program to display Vertical Color Bar

  7. Program to show the use of Logical AND Operator (&) in If Statements

  8. Program to show the use of Comparison operator (==) for comparing Strings

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

  10. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

  11. Program to show the use of Labeled Continue Statement

  12. Program to display bank account

  13. Program sets up a String variable containing a paragraph of text of your choice. Extract the words from the text and sort them into alphabetical order

  14. Program to show the use of For Loop

  15. 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

  16. Program of binary search tree

  17. Program to change characters in a StringBuffer objects and to reverse its contents

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

  19. Program to search an element in an array using Linear Search

  20. Simple Applet which will show life cycle of an Applet