Search This Blog

Wednesday, 15 August 2018

3. Write a multilayered JSP program to evaluate the result of a student.


3. Write a multilayered JSP program to evaluate the result of a student. Consider student name, register number, marks obtained in 5 subjects as input and read them by writing a proper user interface JSP. Evaluate the total marks, percentage marks and grade by writing a process JSP. While evaluating the grade verify whether the student has cleared all the papers. Display the output with proper marks list format by using <TABLE> tag. 
College Name
Marks List
Name of the Student :
Register Number :
Subjects Max. Marks Min. Marks Marks Obtained
1. Subject1 100 40 --
2. Subject2 100 40 --
3. Subject3 100 40 --
4. Subject4 100 40 --
5. Subject5 100 40 --
Total Marks 500 200 --
Percentage Marks: -- %
Grade: ----
Code for Stud11.html:
<!-- 11. HTML Program to read student information -->
<html>
 <head>

 <title>Student Information</title>
 </head>
 <body>
 <h3>Enter Student Details:</h3>
 <form action="Stud11.jsp" method="POST" >
 <table >
 <tr><td>Name:</td><td><input type="text" name="sname" ></td></tr>
 <tr><td>Register Number:</td><td><input type="text" name="regno"></td></tr>
 <tr><td>Sub1:</td><td><input type="text" name="sub1"></td></tr>
 <tr><td>Sub2:</td><td><input type="text" name="sub2"></td></tr>
 <tr><td>Sub3:</td><td><input type="text" name="sub3"></td></tr>
 <tr><td>Sub4:</td><td><input type="text" name="sub4"></td></tr>
 <tr><td>Sub5:</td><td><input type="text" name="sub5"></td></tr>

 <tr><td><input type="submit" value="Submit"></td><td><input type="reset" value="Reset"></td></tr>
 </table>
 </form>
 </body>
</html>
Code for Stud11.jsp:
<!-- 11. JSP Program to evaluate the result of a student and display using TABLE tag. -->  
<html>
<head>
<%@ page import="java.io.*,java.util.*" %>
</head>
<body>
<%
    String sname=request.getParameter("sname");
    String regno=request.getParameter("regno");
    int m1=Integer.parseInt(request.getParameter("sub1"));
    int m2=Integer.parseInt(request.getParameter("sub2"));
    int m3=Integer.parseInt(request.getParameter("sub3"));
    int m4=Integer.parseInt(request.getParameter("sub4"));
    int m5=Integer.parseInt(request.getParameter("sub5"));
    int total_marks;
    float percent;
    String grade="";
    total_marks=m1+m2+m3+m4+m5;
    percent = (float)(total_marks*100) / 500;
  
    if(m1<40 || m2<40 || m3<40 || m4<40 || m5<40)
        grade= "FAIL";
    else
    {
        if(percent >=70)
            grade = "DISTINCTION";
        else if(percent >= 60 && percent < 70)
            grade = "FIRST CLASS";
        else if(percent >= 50 && percent < 60)
            grade = "SECOND CLASS";
        else if(percent >= 40 && percent < 50)
            grade = "PASS";
      
    }

%>
    <CENTER>
    <table border=5 bgcolor="pink" height=800 width=600 >
   
    <caption><font color="blue" size=14>College Name<br>Marks List</font></caption>
  
    <tr><td><b>NAME</b></td><td colspan=3><%=sname%></td></tr>
    <tr><td><b>REGISTER NUMBER</b></td><td colspan=3><%=regno%></td></tr>
    <tr><th>SUBJECTS</th><th>MAX. MARKS</th><th>MIN. MARKS</th><th>MARKS OBTAINED</th></tr>
    <tr align=center><td>SUBJECT1</td><td>100</td><td>40</td><td><%=m1%></td></tr>
    <tr align=center><td>SUBJECT2</td><td>100</td><td>40</td><td><%=m2%></td></tr>
    <tr align=center><td>SUBJECT3</td><td>100</td><td>40</td><td><%=m3%></td></tr>
    <tr align=center><td>SUBJECT4</td><td>100</td><td>40</td><td><%=m4%></td></tr>
    <tr align=center><td>SUBJECT5</td><td>100</td><td>40</td><td><%=m5%></td></tr>
    <tr><td><b>TOTAL</b></td><td colspan=3><%=total_marks%></td></tr>

    <tr><td><b>PERCENT</b></td><td colspan=3><%=percent%>%</td></tr>
    <tr><td><b>GRADE</b></td><td colspan=3><%=grade%></td></tr>
    </table>
    </CENTER>
      
</body>
</html>

2. Write a JSP application to evaluate the salary details of an employee and store the same in the MS Access database table.

2. Write a JSP application to evaluate the salary details of an employee and store the same in the MS Access database table.
<!-- 10. JSP Program to Evaluate Salary Details of an Employee and Store in Database.-->
<html>
<head>
<%@ page import="java.sql.*" %>
</head>
<body bgcolor="beige">
<%
 
    String ename="Mahesh";
    String dept="Finance";
    String des="Manager";
    double bsal=20000;
    double ta=10;
    double da=30;
    double hra=10;
    double pf=10;
    double lic=15;
    double allowance;
    double deduction;
    double gsal;
    double netsal;

    allowance = (bsal*ta)/100 + (bsal*da)/100 + (bsal*hra)/100;
    deduction = (bsal*pf)/100 + (bsal*lic)/100;
    gsal = bsal + allowance;
    netsal = gsal - deduction;
 
    try
    {
        out.println("<h2>Information Stored Successfully!</h2>");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:emp10");
        Statement st=con.createStatement();
        String s="insert into emp10 values('"+ename+"','"+dept+"','"+des+"',"
            +bsal+","+gsal+","+netsal+");";
        st.executeQuery(s);
    }
    catch(Exception e)
    {
        //out.println(e);
    }
%>
</body>
</html>

1. Write a JSP application to read the details of a student and store the same on to the MS Access database.


1. Write a JSP application to read the details of a student and store the same on to the MS Access database.
Code for HTML Program:
 <!--  HTML Program to read student info.-->


<html>
 <head>

 <title>Student Information</title>
 </head>
 <body>
 <h3>Enter Student Details:</h3>
 <form action="Stud9.jsp" method="POST" >
 <table >
 <tr><td>Name:</td><td><input type="text" name="sname" ></td></tr>
 <tr><td>Register Number:</td><td><input type="text" name="regno"></td></tr>
 <tr><td>Course:</td><td> <input type="text" name="course"> </td></tr>

 <tr><td>College:</td><td>    <input type="text" name="college"> </td></tr>
 <tr><td>City:</td><td>    <input type="text" name="city"> </td></tr>

 <tr><td><input type="submit" value="Save in Database" ></td>
 <td><input type="reset" value="Reset" ></td></tr>
 </table>
 </form>
 </body>
</html>

Code for JSP Program:
<!--JSP Program to store Student Information in to the Database.-->
<html>
<head>
<title>Student Information</title>
<%@ page import="java.sql.*, java.util.*"%>
</head>
<body>
<%
    String sname=request.getParameter("sname");
    String regno=request.getParameter("regno");
    String course=request.getParameter("course");
    String college=request.getParameter("college");
    String city=request.getParameter("city");
   
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:stud9");
   
    Statement st=con.createStatement();
    try
    {
        out.println("<h3>Data Saved Successfully!</h3>");
        String s="insert into Stud9 values('"+sname+"','"+regno
            +"','"+course+"','"+college+"','"+city+"');";
        st.executeQuery(s);
      
    }
    catch(Exception e)
    {
        //out.println("Insertion of data failed!");
        //out.println(e);
    }
     
%>
</body>
</html> 

Sunday, 22 July 2018

5. Create a webpage to convert a given text from uppercase to lowercase using JavaScript.

<HTML>
    <HEAD>
    <STYLE Type="text/css">
  input { height:25px; width:100px; color:blue}
  th { text-align:left;}
  </STYLE>
    <SCRIPT  Language="JavaScript">
        function Convert()
        {
            if(( document.forms[0].elements[0].value != "" ) && 
            document.forms[0].elements[0].value != document.forms[0].elements[0].value.toLowerCase() )
            {
                document.forms[0].elements[1].value = document.forms[0].elements[0].value.toLowerCase();
            }
            else
                alert("Enter Text in UPPERCASE!");
        }
    </SCRIPT></HEAD>
    <BODY TEXT=blue BGCOLOR=BEIGE SIZE=22>
    <CENTER>
    <H3>CONVERSION OF TEXT FROM UPPERCASE TO LOWERCASE</H3>
    <FORM>
    <TABLE bgcolor=gray>
    <TR><TH>Enter Text in UpperCase</TH>
    <TH><INPUT TYPE="text" NAME="upper" value="" SIZE=10></TH></TR>
    <TR><TH>Text in LowerCase</TH>
    <TH><INPUT TYPE="text" DISABLED NAME="lower" value=""  SIZE=10></TH></TR>
    <TABLE>
    <br>
    <INPUT TYPE="button" onClick="Convert()" value="CONVERT">
    <INPUT TYPE="reset"  value="RESET">
    </FORM>
    </CENTER>
    </BODY>
</HTML>

4. Create a webpage with two textboxes and command buttons to perform arithmetic operations and display the result in appropriate dialog boxes using JavaScript.


<html>
 <head>
  <title>Arithmetic Operations</title>
  <style type="text/css">
  input { height:25px; width:100px; color:blue}
  th { text-align:left;}
  </style>

 </head>
 <body bgcolor=beige text=blue>
 <center>
 <h1> <u>ARITHMETIC OPERATIONS</u></h1>
 <form>

 <table bgcolor=gray>
 <tr><th>Enter 1st Number</th><th><input type="text" size=10 name=text1></th><tr>
<tr><th>Enter 2nd Number</th><th><input type="text" size=10 name=text2></th><tr>
 </table><br>

  <input type=button value="ADD" onClick="add()">
  <input type=button value="SUBTRACT"  onClick="sub()"><br>
  <input type=button value="MULTIPLY" onClick="multiply()">
  <input type=button value="DIVIDE" onClick="divide()"><br>

 </form>

<script language="JavaScript">
function add()
{
    var result = eval(document.forms[0].elements[0].value) + eval(document.forms[0].elements[1].value);
    alert("SUM = " + result);
}
function sub()
{
    var result = eval(document.forms[0].elements[0].value) - eval(document.forms[0].elements[1].value);
    alert("DIFFERENCE = " + result);
}
function multiply()
{
    var result = eval(document.forms[0].elements[0].value) * eval(document.forms[0].elements[1].value);
    alert("PRODUCT = " + result);
}
function divide()
{
    var result = eval(document.forms[0].elements[0].value) / eval(document.forms[0].elements[1].value);
    alert("QUOTIENT = " + result);
}
</script>
 </center>
 </body>
</html>
FREE Hit Counters