Professional Documents
Culture Documents
<HTML>
<HEAD>
<TITLE>
MONTH CALENDAR
</TITLE>
</HEAD>
<BODY BGCOLOR=LIGHTGREY>
<CENTER>
<TABLE HEIGHT=10% WIDTH=40%>
OUTPUT
Page |2
<HTML>
<HEAD>
<TITLE>
Entry Form
Page |3
</TITLE>
<BODY BGCOLOR=lightgrey>
<FORM>
Name   ::
<INPUT TYPE="TEXT" NAME="NM">
<BR><BR>
Branch   ::
<INPUT TYPE="RADIO" CHECKED="CHECKED"
NAME="COURSE" VALUE="MCA">MCA
MARKS   ::
SUB1 <INPUT TYPE="NUMBER" NAME="MARKS" SIZE=3>
SUB2 <INPUT TYPE="NUMBER" NAME="MARKS" SIZE=3>
SUB3 <INPUT TYPE="NUMBER" NAME="MARKS" SIZE=3>
SUB4 <INPUT TYPE="NUMBER" NAME="MARKS" SIZE=3>
<BR><BR>
GRADE   ::
<INPUT TYPE="RADIO" CHECKED="CHECKED"
NAME="GRADE" VALUE="A">A
<INPUT TYPE="RADIO" NAME="GRADE" VALUE="B">B
<INPUT TYPE="RADIO" NAME="GRADE" VALUE="C">C
<BR><BR>
DOB   ::
DAY<SELECT NAME="DAY">
<OPTION VALUE="1">1
<OPTION VALUE="2">2
<OPTION VALUE="3">3
<OPTION VALUE="4">4
<OPTION VALUE="5">5
<OPTION VALUE="6">6
<OPTION VALUE="7">7
<OPTION VALUE="8">8
<OPTION VALUE="9">9
<OPTION VALUE="10">10
<OPTION VALUE="11">11
<OPTION VALUE="12">12
<OPTION VALUE="13">13
<OPTION VALUE="14">14
<OPTION VALUE="15">15
<OPTION VALUE="16">16
Page |4
<OPTION VALUE="17">17
<OPTION VALUE="18">18
<OPTION VALUE="19">19
<OPTION VALUE="20">20
<OPTION VALUE="21">21
<OPTION VALUE="22">22
<OPTION VALUE="23">23
<OPTION VALUE="24">24
<OPTION VALUE="25">25
<OPTION VALUE="26">26
<OPTION VALUE="27">27
<OPTION VALUE="28">28
<OPTION VALUE="29">29
<OPTION VALUE="30">30
<OPTION VALUE="31">31
</SELECT>
MONTH::
<SELECT NAME="MONTH">
<OPTION VALUE="1">1
<OPTION VALUE="2">2
<OPTION VALUE="3">3
<OPTION VALUE="4">4
<OPTION VALUE="5">5
<OPTION VALUE="6">6
<OPTION VALUE="7">7
<OPTION VALUE="8">8
<OPTION VALUE="9">9
<OPTION VALUE="10">10
<OPTION VALUE="11">11
<OPTION VALUE="12">12
</SELECT>
YEAR::
<SELECT NAME="YEAR">
<OPTION VALUE="1980">1980
<OPTION VALUE="1981">1981
<OPTION VALUE="1982">1982
<OPTION VALUE="1983">1983
<OPTION VALUE="1984">1984
<OPTION VALUE="1985">1985
<OPTION VALUE="1986">1986
<OPTION VALUE="1987">1987
<OPTION VALUE="1988">1988
<OPTION VALUE="1989">1999
<OPTION VALUE="1990">1990
<OPTION VALUE="1991">1991
<OPTION VALUE="1992">1992
</SELECT>
<BR><BR>
Page |5
OUTPUT
Q5 .W.A.P in java to create a user Login form and insert validation to check
whether Password is valid or not with the help Java Script.
<HTML>
<HEAD>
<TITLE>
Password
</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
function notEmpty(elem,helperMsg)
{
Page |6
alert(elem.value);
if(elem.value=="")
{
alert(helperMsg);
elem.focus();
}
}
function checkEqual(helperMsg)
{
if(req2.value.!=req3.value)
{
alert(helperMsg);
req2.focus();
return false;
}
return true;
}
</SCRIPT>
</HEAD>
<BODY>
<center>
<table>
<tr><th align=right>USER NAME ::</th>
<th><INPUT TYPE="TEXT" id='req1'
onBlur="notEmpty(document.getElementById('req1'), 'Please Enter User name....!')">
</th></tr>
<BR></BR>
<tr>
<th align=right>PASSWORD ::</th>
<td><INPUT TYPE="PASSWORD" id='req2'
onBlur="notEmpty(document.getElementById('req2'), 'Please Enter Password of atleast
5 character long......!')">
</td></tr>
<BR></BR>
<tr>
<th align=right>REENTER PASSWORD ::</th>
<td><INPUT TYPE="PASSWORD" id='req3'
onBlur="notEmpty(document.getElementById('req3'), 'Please Enter Password of atleast
5 character long......!')">
</td>
</tr>
<BR></BR>
<tr>
<th colspan=2 align=center>
<INPUT TYPE="BUTTON" value="Validated" onClick="checkEqual('please enter the
same password......!')">
</th>
<td></td>
</tr>
</table>
Page |7
</center>
</BODY>
</HTML>
OUTPUT
Q6 .W.A.P in HTML & Java Script to take to number from the user and
perform the arithmetic operation as per the user choice.
<html>
<head>
<SCRIPT LANGUAGE=javascript>
var a,b,result;
function add1()
{
a=parseInt(document.f1.t1.value);
b=parseInt(document.f1.t2.value);
result=a+b;
Page |8
alert("result:"+result);
}
function sub1()
{
a=parseInt(document.f1.t1.value);
b=parseInt(document.f1.t2.value);
result=a-b;
alert("result:"+result);
}
function mul1()
{
a=parseInt(document.f1.t1.value);
b=parseInt(document.f1.t2.value);
result=a*b;
alert("result:"+result);
}
function div1()
{
a=parseInt(document.f1.t1.value);
b=parseInt(document.f1.t2.value);
result=a/b;
alert("result:"+result);
}
</SCRIPT>
</head>
<body>
<form name=f1>
<input type=text name=t1 size=3>
<input type=text name=t2 size=3><br><br>
<input type=button value=ADD onClick=add1()>
<input type=button value=MUL onClick=mul1()><br>
<input type=button value=SUB onClick=sub1()>
<input type=button value=DIV onClick=div1()><br><br>
<center>
<input type=reset value=" RESET " size=7></center>
</form>
</body>
</html>
OUTPUT
Page |9
Q7 . W.A.P in HTML & Java Script to take three subject marks of a student
and calculate total marks and the Grade of student.
<html>
<head>
<title>marks</title>
<script language=javascript>
<!--
function total()
{
var m1=parseInt(document.f1.m1.value);
P a g e | 10
var m2=parseInt(document.f1.m2.value);
var m3=parseInt(document.f1.m3.value);
f1.t.value=m1+m2+m3;
}
function grade()
{
var avg=parseInt(f1.t.value/3);
if(avg>90 && avg<=100)
f1.g.value='O'
else if(avg>80)
f1.g.value='E';
else if(avg>70)
f1.g.value='A';
else if(avg>60)
f1.g.value='B';
else if(avg>50)
f1.g.value='c';
else if(avg>40)
f1.g.value='D';
else
f1.g.value='F';
}
//-->
</script>
<head>
<body>
<center>
<form name=f1>
<table border=2>
<tr>
<th>Marks1 :</th>
<td><input type="text" name=m1></td>
</tr>
<tr>
<th>Marks2 :</th>
<td><input type="text" name=m2></td>
</tr>
<tr>
<th>Marks3 :</th>
<td><input type="text" name=m3></td>
</tr>
<tr align=center>
<td><input type="button" value="Total :" onClick="total()"></td>
<td><input type="text" name=t></td>
</tr>
<tr align=center>
P a g e | 11
OUTPUT
class Prime
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=100;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0)
break;
}
P a g e | 12
if(i==j)
System.out.println(i);
}
}
}
OUTPUT
class Prime1
{
int i,j;
void check()
{
for(i=1;i<=100;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0)
break;
}
if(i==j)
P a g e | 13
System.out.println(i);
}
}
public static void main(String args[])
{
prime1 obj=new prime1();
obj.check();
}
}
OUTPUT
Q10. WAP in JAVA to generate the table of given no into specific format.
import java.util.Scanner;
class Table
{
public static void main(String args[])
{
int i;
Scanner s=new Scanner(System.in);
System.out.print("Enter any no::");
int t=s.nextInt();
for(i=1;i<=10;i++)
System.out.print(t+" ");
System.out.println(" ");
for(i=1;i<=10;i++)
System.out.print(i+" ");
System.out.println(" ");
P a g e | 14
for(i=1;i<=10;i++)
System.out.print((t*i)+" ");
}
}
OUTPUT
class Emp
{
float basic,da,ta,net;
String name;
void show()
{
System.out.print("\n Employee Name :: "+name);
System.out.print("\n Basic Salary :: "+basic);
System.out.print("\n DA :: "+da);
System.out.print("\n TA :: "+ta);
System.out.print("\n Net salary :: "+net);
}
Emp(String n,float b)
{
name=n;
P a g e | 15
basic=b;
da=b*40/100;
ta=b *30/100;
net=b+da+ta;
}
public static void main(String args[])
{
Emp obj=new Emp("Pawan kumar singh",25000.00f);
obj.show();
}
}
OUTPUT
Q12 . WAP to take input base and height of triangle and calculate its area.
import java.util.Scanner;
public class Triangle
{
public static void main(String args[])
{
int b,h;
double area;
Scanner s=new Scanner(System.in);
System.out.print("\n Enter base of triagle ::");
b=s.nextInt();
System.out.println("\n Enter height of tringle ::");
h=s.nextInt();
area=0.5*b*h;
System.out.println("\n Area of triagle is ::"+area);
}
}
OUTPUT
P a g e | 16
import java.util.Scanner;
class Fact
{
int i,j;
int fact(int n)
{
if(n==1)
return 1;
else
return(n*fact(n-1));
}
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.print("\n Enter any no::");
int n=s.nextInt();;
Fact obj=new Fact();
System.out.print("\n Factorial="+obj.fact(n));
}
P a g e | 17
OUTPUT
import java.util.Scanner;
public class Cylinder
{
public static void main(String args[])
{
int r,h;
double vol;
Scanner s=new Scanner(System.in);
System.out.print("\n Enter radius of cylinder ::");
r=s.nextInt();
System.out.print("\n Enter height of cylinder ::");
h=s.nextInt();
vol=3.14*r*r*h;
System.out.println("\n Volume of cylinder is ::"+vol+"\n");
}
}
OUTPUT
P a g e | 18
Q15. WAP to find quadratic equation and find out two roots are equal or
complex.
import java.util.Scanner;
public class Quad1
{
public static void main(String args[])
{
int a,b,c,d;
Scanner s=new Scanner(System.in);
System.out.print("\n Quadratic equation is (ax^2 + bx +c) ");
System.out.print("\n Enter value of coeficient a ::");
a=s.nextInt();
System.out.print("\n Enter value of coeficient b ::");
b=s.nextInt();
System.out.print("\n Enter value of constant c ::");
c=s.nextInt();
d=b*b-4*a*c;
if(d!=0)
System.out.print("\n Two roots exist");
if(d<0)
System.out.print("\n Roots are complex");
if(d==0)
P a g e | 19
OUTPUT
}
}
OUTPUT
Q17 . WAP in JAVA to create a class student having attributes name, roll,
marks. It should have appropriate method for setting and getting the
attributes of student class . initialize using parameterize constructor . create
another class student- Demo in this class you have two methods create
Student and display Student . in create Student program should asked the
user how many student wants to create. Display method take parameter of
student type array and display all student.
for(int i=0;i<s.length;i++)
{
s[i]=new student();
s[i].setRoll();
s[i].setName();
s[i].setMarks();
}
}
void displayStud(student [] s)
{
System.out.print("\nRoll\tName\tMarks");
for(int i=0;i<s.length;i++)
{
System.out.print("\n"+s[i].getRoll());
System.out.print("\t"+s[i].getName());
System.out.print("\t"+s[i].getMarks());
P a g e | 22
}
System.out.println();
}
public static void main(String args[])
{
System.out.print("\n Enter no of student::");
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
student s[]=new student[n];
studentDemo obj = new studentDemo();
obj.createStud(s);
obj.displayStud(s);
}
}
OUTPUT
P a g e | 23
Q18. Define a 3*3 array and find out sum of each row and store in one
dimensional array and find out the largest element in each row.
//DEFINE 3*3 ARRAY & FIND SUM OF EACH ROW AND COLUMN & LARGEST
ELEMENT IN EACH ROW
import java.util.Scanner;
class AddMat
{
P a g e | 24
OUTPUT
P a g e | 25
import java.lang.*;
abstract class Car
{
int model;
int speed;
float price;
Car(int a,int b,float f)
{
model=a;
speed=b;
price=f;
}
void start()
{
System.out.print("\n Car Started..........");
}
void stop()
{
System.out.print("\n Car Stoped..........");
}
abstract void run();
void display(Car c)
{
c.run();
}
}
class Ferron extends Car
{
String type;
Ferron(String t,int a,int b,float f)
{
super(a,b,f);
type=t;
}
void run()
{
System.out.print("\n Ferron Running.......with speed="+speed+" Model="+model+"
Price="+price+" Type="+type);
}
}
class Nano extends Car
{
String type;
Nano(String t,int a,int b,float f)
{
super(a,b,f);
type=t;
}
void run()
{
P a g e | 27
Q21.Create a user table and another table student which contain student
details . WAP in java to take input from user name and password and
compare with user table if exist then display all student records otherwise a
message invalid user.
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
class Login extends Frame implements ActionListener
{
P a g e | 29
Panel p1,p2,p3;
Label l1,l2;
Font f;
TextField tf1,tf2;
Button b1,b2;
Login()
{
setLayout(new GridLayout(3,1));
p1=new Panel();
p2=new Panel();
p3=new Panel();
p1.add(l1);
p2.add(l2);
tf1=new TextField(10);
tf2=new TextField(10);
p1.add(tf1);
p2.add(tf2);
b1=new Button("SUBMIT");
b2=new Button("CANCEL");
p3.add(b1);
p3.add(b2);
add(p1);
add(p2);
add(p3);
b1.addActionListener(this);
b2.addActionListener(this);
setVisible(true);
setSize(300,300);
}
public void actionPerformed(ActionEvent ae)
{
try
{
if(ae.getSource()==b1)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
conn=DriverManager.getConnection("jdbc:odbc:jj1","system","suvi");
P a g e | 30
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from login");
int flag=0;
String password=tf1.getText();
String name=tf2.getText();
while(rs.next())
{
if(name.equals(rs.getString(2)) && password.equals(rs.getString(1)))
{
flag=1;
break;
}
}
if(flag==1)
{
rs=st.executeQuery("select * from stud");
while(rs.next())
{
System.out.print("\n"+ rs.getString(1));
System.out.print("\t"+ rs.getString(2));
System.out.print("\t"+ rs.getString(3));
}
}
else
{
System.out.print("\nUser Id is Invalied.....");
}
conn.close();
st.close();
}
else
{
}
}
catch(Exception e)
{
System.out.print(e);
}
}
}
class SanLogin
{
public static void main(String args[])
{
Login o=new Login();
}
} OUTPUT
P a g e | 31
Q22. WAP to insert student information into stud table and finally display all
existing records.
import java.sql.*;
import java.util.*;
class StudInfo
{
public static void main(String aregs[])throws Exception
{
Connection con = null;
Statement stmt =null;
PreparedStatement pt=null;
ResultSet rs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:jj1","system","suvi");
stmt = con.createStatement();
Scanner sc = new Scanner(System.in);
P a g e | 32