Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 84

Tanishq Bhatia

XII-A

1| Page
Table of Contents

Certificate
03
ACKNOWLEDGEMENT
04

05-73 Java Applications

HTML
74
75
MY MYSQL

2| Page
CERTIFICATE

This is to certify that Mr. Shashwat Arya of class XII of


Laurel High The School, New Delhi, has completed her
practical file under my guidance. he has taken proper care
and showed utmost sincerity in completing this practical
file.I certify that this project is up to my expectations and
as per the guidelines issued by CBSE.
……………………
Signature of Teacher/Guide
Name: Bhavna Malik

3| Page
ACKNOWLEDGEMENT

I express my gratitude to Bhavna Malik my Informatics Practices


and guide who guided me through my practical file and gave me
valuable suggestions and guidance for completing the practical file.
She helped me to understand the intricate issues involved in making
the practical file, besides effectively presenting it. These intricacies
would have been lost otherwise. My practical file has been a success
only because of her guidance.

Name of the Student: Shashwat arya


Roll NO.:

4| Page
5| Page
Q1: Develop a compound interest calculator application as per given screen snapshot to calculate total
amount for given amount, rate of interest and time using (A= P(1+R/100) and interest I= A-P.

DESIGN VIEW

OUTPUT

6| Page
CODING
private void closeActionPerformed (java.awt.event.ActionEvent evt){

// TODO add your handling code here:


System.exit(0);

private void clearActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");

private void calculateActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
double p=Double.parseDouble(t1.getText());
double r=Double.parseDouble(t2.getText());
double t=Double.parseDouble(t3.getText());
double a=p*Math.pov (1+r/100,t);
t4.setText(""+a);
double i-a-p;
t5.setText(""+i);

7| Page
Q2 a java application to print a pattern for given character and steps, as per given screen shots.

DESIGN VIEW

OUTPUT

8| Page
CODING
private void clearActionPerformed (java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
t1.setText("");
t2.setText("");
ta.setText("");

private void generateActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
String ch=t1.getText();
int r=Integer.parseInt(t2.getText());
int i, j;
for(i=1;i<r;i++) {
for(j=1;j<=i; j++)
ta.append(ch);
ta.append("\n");

9| Page
Q3.Develop a simple calculator as per given screen shot to implement +,-,* and / operations. The text
boxes get cleared when “c” butter is clicked.

DESIGN VIEW

OUTPUT

10 | P a g e
CODING
private void clearActionPerformed (java.awt.event.ActionEvent evt)

// TODO add your handling code here:


t1.setText("");
t2.setText("");
t3.setText("");

private void addActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
int c=a+b;
t3.setText("+c);

private void subtractActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int a=Integer.parseInt(ti.getText());
int b=Integer.parseInt(t2.getText());
int c=a-b;
t3.setText(""+c);

private void multiplyActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int a=Integer.parseInt(ti.getText());
int b=Integer.parseInt(t2.getText());

11 | P a g e
int c=a*b;
t3.setText(""+c);

private void divideActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
int c=a/b;
t3.setText(""+c);

Q4.Develop a application for calculating amount based on the distance and weight of goods.

DESIGN VIEW

OUTPUT

12 | P a g e
CODING
private void closeActionPerformed (java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);

private void calculateActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
int w=Integer.parseInt(t3.getText());
int d=Integer.parseInt(t4.getText());
int c=1;
if(w>=500)
if (d>=100)
c=5;
else if (d>=10 && d<100)
c=6;
else
c=7;
if(w<500)
if (d>=100)
c=8;
else
c=5;
int a=w*d;
t5.setText (
+a);
13 | P a g e
Q5.Develop a application to complete the sum of digits of given number.

DESIGH VIEW

OUTPUT

14 | P a g e
CODING
private void closeActionPerformed (java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);

private void calculateActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
int w=Integer.parseInt(t3.getText());
int d=Integer.parseInt(t4.getText());
int c=1;
if(w>=500)
if (d>=100)
c=5;
else if (d>=10 && d<100)
c=6;
else
c=7;
if(w<500)
if (d>=100)
c=8;
else
ic=5;
int a=w*d;
t5.setText(""+a);

15 | P a g e
Q6.Program to find the area and perimeter of the circle, rectangle and square.

DESIGN VIEW

16 | P a g e
OUTPUT

CODING
private void squareActionPerformed (java.awt.event.ActionEvent evt) {
// TODO add your handling code here
area.setVisible(true);
perimeter.setVisible(true);
17 | P a g e
1.setVisible(false);
b.setVisible(false);
r.setVisible(false);
3.setVisible(true);
ti.setVisible(false);
t2.setVisible(false);
t3.setVisible(false);
t4.setVisible(true);

private void circleActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
area.setVisible(true);
perimeter.setVisible(false);
1. setVisible(false);
b.setVisible(false);
r.setVisible(true);
s.setVisible(false);
t1.setVisible(false);
t2.setVisible(false);
t3.setVisible(true);
t4.setVisible(false);

private void rectangleActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
area.setVisible(true);
perimeter.setVisible(true);
1.setVisible(true);
b.setVisible(true);
r.setVisible(false);
3.setVisible(false);
t1.setVisible(true);
t2.setVisible(true);
t3.setVisible(false);
t4.setVisible(false);

private void generateActionPerformed (Java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
perimeter.setVisible(false);
int i, b, 3, opt=0;
if (circle.is Selected()) {
opt=1;
else
if (rectangle. isSelected()) {
opt-2;
else
if (square.isSelected()) {

18 | P a g e
opt=3;
switch (opt)
//circle
case 1:
double r-Double.parseDouble(t3.getText());
if (area.isSelected()) {
double pi-Math.PI;
double area-pi*r*r;
t5.setText ("Area of ciecle is: " + area);

//rectangle
case 2:
1-Integer.parseInt(ti.getText());
b=Integer.parseInt(t2.getText());
if (area.isSelected()) {
double area=l*b;
t5.setText ("Area of rectangle: " + area);
else
if (perimeter.isSelected()) {
double perimeter=2* (1+b);
t5.setText ("Perimeter of rectangle: " + perimeter);
// square
case 3:
s=Integer.parseInt(t4.getText());
if(area.isSelected()) {
double area=3*3;
t5.setText ("Area of square: " + area);
else
if (perimeter.isSelected()) {
double perimeter=4*3;
t5.setText ("Perimeter of square: " + perimeter);

//rectangle
case 2:
1-Integer.parseInt(ti.getText());
b=Integer.parseInt(t2.getText());
if (area.isSelected()) {
double area=l*b;
t5.setText ("Area of rectangle: " + area);
else
if (perimeter.isSelected()) {
double perimeter=2* (1+b);
t5.setText ("Perimeter of rectangle: " + perimeter);
// square
case 3:
s=Integer.parseInt(t4.getText());
if(area.isSelected()) {
19 | P a g e
double area=3*3;
t5.setText ("Area of square: " + area);
else
if (perimeter.isSelected()) {
double perimeter=4*3;
t5.setText ("Perimeter of square: " + perimeter);

Q7.Program to find deposit, withdrawal and check the status of the account.

DESIGN VIEW
20 | P a g e
OUTPUT

CODING
21 | P a g e
private void cmdCalcActionPerformed (java.awt.event. ActionEvent evt) {

int R, eng, acc, bst, inf, eco, tot; // Marks and total
float per;
String Name, Gr="";
R- Integer.parseInt(txtRoll.getText());
eng - Integer.parseInt(txtEng.getText());
acc - Integer.parseInt(txtAcc.getText());
bst - Integer.parseInt(txtBst.getText());
inf - Integer.parseInt(txtInf.getText());
eco - Integer.parseInt(txtEco.getText();
// Total mark
tot - eng + acc + bst + inf + eco;
// Percentage
per - tot / 5;
if (per >= 90)
Gr = "A+";
else
if (per >= 80 && per < 90)
Gr = "A";
else
if (per >= 70 && per < 80)
Gr="B";
else
if (per >= 60 && per < 70)
Gr = "C";
else
if (per >= 50 66 per < 60)
Gr - "D";

else
if (per < 50)
Gr = "F";
// Displaying total, percentage and grade
txtTotal.setText (Integer.toString(tot));
txt Per.setText (Float.toString(per));
txtGr.setText (Gr);

private void cmdExitActionPerformed (java.awt.event. ActionEvent evt) {


System.exit(0);

22 | P a g e
Q8.Develop a application as per given screen shot to add, remove the given members of list and display
the selected item in a text field using list control.

DESIGN VIEW

OUTPUT

CODING
23 | P a g e
private void addActionPerformed (java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int a Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
int c=Integer.parseInt(t3.getText());
int d=a+b+c;
t4.setText(""+d);

private void averageActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
int c=Integer.parseInt(t3.getText());
int d=(a+b+c)/10;
t4.setText(""+d);

private void maximumActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
int c=Integer.parseInt(t3.getText());
int max=a;
if (b>max)
max=b;
if (c>max)
max=c;
t4.setText(""+max);

24 | P a g e
Q 9.Develop a application for happy shopping – a retail chain involved in sales of readymade garments. The
happy shopping offers discount to its members holding platinum, gold and sliver card. The 10% discount is given
to platinum, 5% to gold and 3% silver card holder on sale amount.

DESIGN VIEW

OUTPUT

25 | P a g e
CODING
private void cmdListActionPerformed (java.awt.event.ActionEvent evt) {
// Creating a string object City
String City = txtCity.getText();
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) Listi.getModel();
// Method to add elements into Listi control
dModel.addElement (City);
// Sets the data model for jListi control
jListi.setModel (dModel);

private void cmdlcActionPerformed (java.awt.event.ActionEvent evt) {


// Creating a List Model object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel - (DefaultListModel) Listi.getModel();
1/ Clears the jListi through DefaultListModel
dModel.clear();

private void cmdComboActionPerformed (java.awt.event.ActionEvent evt) {


// Creating a String object City
String City = txtCity.getText();
// Creating a ComboBoxModel object cModel to perform
// DefaultComboBoxModel method operations
DefaultComboBoxModel cModel = (DefaultComboBoxModel) ComboBox1.getModel();
// Method to add elements into jComboBox1 control
cModel.addElement (City);
// Sets the data model for j ComboBoxl control
j ComboBox1.setModel (cModel);

private void cmdComboActionPerformed (java.awt.event.ActionEvent evt) {


// Creating a String object City
String City = txtCity.getText();
// Creating a ComboBoxModel object cModel to perform
// DefaultComboBoxModel method operations
DefaultComboBoxModel cModel = (DefaultComboBoxModel) ComboBox1.getModel();
// Method to add elements into jComboBox1 control
cModel.addElement (City);
// Sets the data model for j ComboBoxl control
j ComboBox1.setModel (cModel);

private void cmdCCActionPerformed (java.awt.event. ActionEvent evt) {


// Creating a ComboBoxModel object cModel to perform
// DefaultComboBoxModel method operations
DefaultComboBoxModel cModel = (DefaultComboBoxModel) ComboBox1.getModel();
// Clears the jComboBox1 through DefaultComboBoxModel
cModel.removeAllElements();

26 | P a g e
private void cmdclearActionPerformed (java.awt.event.ActionEvent evt) {
txtCity.setText("");

private void cmdComboActionPerformed (java.awt.event. ActionEvent evt) {


// Creating a string object City
String City = txtCity.getText();
// Creating a ComboBoxModel object cModel to perform
// DefaultComboBoxModel method operations
DefaultComboBoxModel cModel = (DefaultComboBoxModel) ComboBox1.getModel();
// Method to add elements into jComboBox1 control
cModel.addElement (City);
// Sets the data model for jComboBox1 control
jComboBox1.setModel (cModel);

private void cmdLCIndActionPerformed (java.awt.event. ActionEvent evt) {


// Creating a string object City
String City - (String) Listi.getSelectedValue();
int ind = jList1.getSelectedIndex();
if (Listi.isSelectedIndex(ind)) {
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) Listi.getModel();
// Remove the data at ind position
dModel.remove(ind);
// This displays the deleted item in a message box.
// Add the line, at top of the source code:
// import javax.swing.JOptionPane;
JOptionPane.showMessageDialog (this, "Deleted name " + City);
jListi.setModel (dModel);
}

else
JOptionPane. shovMessageDialog(this, "Note name is selected from list");

27 | P a g e
Q10.Develop a billing application for happy application shopping-a retail chain involved in sales of
readymade garments.The happy shopping offers discount to its members holding platinum,gold and
silver card.The 10% discount is given to platinum,5% to gold and silver card holder on sale amount.

DESIGN VIEW

OUTPUT

28 | P a g e
CODING
private void cmdClearActionPerformed (java.awt.event. ActionEvent evt) {
txtPID.setText("");
txtDesc.setText("");
txtQty.setText("");
txtPrice.setText("");
txtSub.setText("");
txtTax.setText("");
txtCharge.setText("");
txtTotal.setText("");
optA.setSelected(true);

private void cmdExitActionPerformed (java.awt.event.ActionEvent evt) {


System.exit(0);

private void cmdCalcActionPerformed (java.awt.event. ActionEvent evt) {


// Initializing variables for calculation
float subTot = 0, charge=0, tax = 0, Total=0;
int qty = Integer.parseInt(txtQty.getText());
float uPrice = Float.parseFloat(txtPrice.getText());
// Calculating sub total and tax
subTot = qty * Price;
tax = subTot * (float) 6.5/100;
// Finding charge depending category of city
if (opta.isSelected())
charge=2000;
else
if (optB.isSelected())
charge=3000;
else
if (optc.isSelected())
charge=3500;
// Calculating total
Total = subTot + tax + charge;
// Displaying calculated result
txtSub.setText (String.valueof(subTot));
txtTax.setText (String.valueof(tax));
txtCharge.setText (String.valueOf (charge));
txtTotal.setText (String.valueof (Total));

29 | P a g e
Q11.Thr entertainment paradise –theatre in delhi wants to develop a computerized booking system. The proposal
interface is given below.the theatre offers different types of seats.the ticket rates are: stalls- a discount -652/-, circle- 750/-,
upper class-850/-.a discount is given of 10

DESIGN VIEW

OUTPUT

30 | P a g e
CODING
private void exitActionPerformed (java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);

private void calculateActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:
double a=0, d=0, n=0;
int q=Integer.parseInt(t2.getText());
double r=Double.parseDouble(t3.getText());
a=q*r;
if (platinum. isSelected())
d=a*0.10;
else
if (gold.isSelected())
d=a*0.05;
else
d=a*0.03;
n-a-d;
t4.setText(""+a);
t5.setText("+d);
t6.setText(""+n);

31 | P a g e
Q12 . Abc consultancy is a placement organization, assist job seekers. The
entry form has to be designed to facilitate the registration process with the
following features.

DESIGN VIEW

OUTPUT

32 | P a g e
CODING
private void calculateActionPerformed (java.awt.event. ActionEvent evt)
// TODO add your handling code here:
double d=0;
int s=Integer.parseInt(t4.getText());
int p=0;
if (box.isSelected())
p=1000;
else
if (stall.isSelected())
p=625;
if (circle.isSelected())
p=750;
else
if (upperclass.isSelected())
p=850;
double a=p*3;
if (cash.isSelected())
d=8;
else
if (credit.isSelected())
d=5;
else
d=10;
double n-a-d;
t2.setText(""+d);
t3.setText(""+n);

33 | P a g e
.
Q 13 Develop a application to avon tools has computerize its billing after
entering he sufficient data entered.

DESIGN VIEW

OUTPUT

34 | P a g e
CODING
private void submitActionPerformed (java.awt.event. ActionEvent evt) {
// TODO add your handling code here:
String n=t1.getText();
String title="";
if (m.isSelected())
title="Mr.";
else
title="Mrs";
String stream="";
if(science.isSelected())
stream="science";
else
if (commerce.isSelected())
stream="commerce";
else
stream="arts";
String qualification="";
if(s.isSelected())
qualification="3";
if(g.isSelected()).
qualification="graduate";
if (pg.isSelected())
qualification="post graduate";
JOptionPane.showMessageDialog(null, title+3+"You are registered for"
+stream+qualification);

private void gActionPerformed (java.awt.event. ActionEvent evt) {


// TODO add your handling code here:

35 | P a g e
if(g.isSelected())
3.setSelected (true);

private void pgActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if(pg.isSelected())
3.setSelected (true);
g.setSelected(true);

Q14.The fashion gallery a leading garments shop wants to develop an


application to calculate the discount . The following functionalities are
expected.

DESIGN VIEW

OUTPUT

36 | P a g e
CODING
private void CLEARActionPerformed (java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
t1.setText("");
t2.setText("");
t3.setText("");

private void CALCULATEActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int w, a, a;
if (m. isSelected())
w=140;
else
w=160;
if (3.isSelected())
W+=50;
d=Integer.parseInt(t2.getText());
a=d*w;
t3.setText(""+a);

37 | P a g e
Q 15.Develop a application to avon tools has computerize its billing after
entering he sufficient data entered.

DESIGN VIEW

38 | P a g e
OUTPUT

CODING
private void EXITActionPerformed (java.awt.event. ActionEvent evt) {
// TODO add your handling code here:
int ans=0;
ang=JOptionPane.showConfirmDialog(null,"Do you want to Exit");
if (ang==JOptionPane. YES_OPTION);
System.exit(ans);

private void CalAmtActionPerformed (java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int b=Integer.parseInt(t2.getText());
double a=b-d;
t4.setText("+d);

39 | P a g e
private void EXITActionPerformed (java.awt.event. ActionEvent evt) {
// TODO add your handling code here:
int ans=0;
ang=JOptionPane.showConfirmDialog(null,"Do you want to Exit");
if (ang==JOptionPane. YES_OPTION);
System.exit(ans);

Q16.Understanding and use of variables of float and other data types.


Develop a simple Calculator application as per given screen snapshot, to
implement +, -, x and / operations. The text boxes get cleared when
‘C’ button is clicked.

DESIGN VIEW

40 | P a g e
OUTPUT

CODING
private void BtnPlusActionPerformed(java.awt.event.ActionEvent evt) { float x,y,z;
x=Float.parseFloat(TxtNum1.getText());
y=Float.parseFloat(TxtNum2.getText());
z=x+y;
TxtResult.setText(""+z);
}

private void BtnMinusActionPerformed(java.awt.event.ActionEvent evt) {


float x,y,z;
x=Float.parseFloat(TxtNum1.getText());
41 | P a g e
y=Float.parseFloat(TxtNum2.getText());
z=x-y;
TxtResult.setText(""+z);
}

private void BtnMulActionPerformed(java.awt.event.ActionEvent evt) {


float x,y,z;
x=Float.parseFloat(TxtNum1.getText());
y=Float.parseFloat(TxtNum2.getText());
z=x*y;
TxtResult.setText(""+z);
}

private void BtnDivActionPerformed(java.awt.event.ActionEvent evt) {


float x,y,z;
x=Float.parseFloat(TxtNum1.getText());
y=Float.parseFloat(TxtNum2.getText());
z=x/y;
TxtResult.setText(""+z);
}
private void BtnClearActionPerformed(java.awt.event.ActionEvent evt) {
TxtNum1.setText("");
TxtNum2.setText("");
TxtResult.setText("");
}
private void BtnOffActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}

42 | P a g e
Q17: Understanding and use of Nested conditions in the Real life applications.
A Quick Fox Transport Co. wants to develop an application for calculating
amount based on distance and weight of goods.
The charges (Amount) to be calculated as per rates given below.

Distance Weight Charges per Km.


>=500 Km >=100 kg. Rs. 5/-
>=10 and <100 kg. Rs. 6/-
< 10 kg. Rs. 7/-
<500 Km >=100 Kg. Rs.8/-
<100 Kg. Rs.5/-

DESIGN VIEW

OUTPUT

44 | P a g e
CODING
private void BtnCalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
float amt;
float wt=Float.parseFloat(TxtWeight.getText());
float km=Float.parseFloat(TxtDist.getText());
if (km >= 500)
{
if (wt>=100)
amt = km*5;
else if (wt >= 10)
amt = km * 6;
else
amt = km *7;
}
else
{
if (wt >= 100)
amt = km*8;
else
amt = km *10;
}
TxtAmt.setText(""+amt);
}

private void BtnExitActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
System.exit(0);
}

45 | P a g e
Q19. Develop a Billing application for Happy Shoping- A retail chain involved in
sales of Readymade garments. The happy Shoping offers discount to its
members holding Platinum, Gold and Silver card.
The 10% discount is given to Platinum card, 8% to Gold Card and 5% to
Silver Card holders on sales amount.

DESIGN VIEW

OUTPUT

46 | P a g e
Coding: private void BtnCalculateActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
float rt,qty,amt,dis,net;
rt=Float.parseFloat(TxtRate.getText());
qty=Float.parseFloat(TxtQty.getText());
amt=rt*qty;
if(RdBtnPlatinum.isSelected()==true)
dis=amt*10/100;
else if(RdBtnGold.isSelected() == true)
dis=amt*8/100;
else
dis=amt*5/100;
net=amt-dis;
TxtAmt.setText(""+amt);
TxtDisc.setText(""+dis);
TxtNet.setText(""+net);
}

private void BtnCloseActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
System.exit(0);
}

47| P a g e
Q20 : To make a program which appends the information given.

DESIGN VIEW

OUTPUT

48 | P a g e
Code : For Submit Button –

String a = t1.getText();

String b = t9.getText();

String c = t3.getText();

String d = t4.getText();

String e = t5.getText();

String f = t6.getText();

ta.append("Name : "+a+"\n"+"House no :"+b+"\n"+"Building

:"+c+"\n"+"Street :"+d+"\n"

+"City :"+e+"\n"+"State :"+f+"\n");

49 | P a g e
Q21: To make a calculator.

DESIGN VIEW

OUTPUT

50 | P a g e
CODING
For add button :

Double n1,n2,n3;

n1 = Double.parseDouble(t1.getText());

n2 = Double.parseDouble(t2.getText());

n3 = n1+n2;

l1.setText(""+n3);

For subtract button :

Double n1,n2,n3;

n1 = Double.parseDouble(t1.getText());

n2 = Double.parseDouble(t2.getText());

n3 = n1-n2;

l1.setText(""+n3);

For multiply button :

Double n1,n2,n3;

n1 = Double.parseDouble(t1.getText());

n2 = Double.parseDouble(t2.getText());

n3 = n1*n2;

l1.setText(""+n3);

51 | P a g e
For divide button :

Double n1,n2,n3;

n1 = Double.parseDouble(t1.getText());

n2 = Double.parseDouble(t2.getText());

n3 = n1/n2;

l1.setText(""+n3);

For clear button :

t1.setText("");

t2.setText("");

l1.setText("");

52 | P a g e
Q22 : To make a program that counts integers between two given integers.

DESIGN VIEW

OUTPUT

53 | P a g e
CODING
For Count button :

double i =Double.parseDouble(t1.getText());

double j =Double.parseDouble(t2.getText());

if(j<i)

{for(;j<=i;j++){

ta.append(" "+j);}

else

{for(;i<=j;i++){

ta.append(" "+i);

}}

54 | P a g e
Q23 : To create a LCM and HCF calculator.

DESIGN VIEW

OUTPUT

55 | P a g e
CODING
For Calculate Button :

private void CalculateActionPerformed(java.awt.event.ActionEvent evt) {

int a=Integer.parseInt(one.getText());

int b=Integer.parseInt(two.getText());

int w, x=a, y=b, z;

while (y!=0)

{w=y;

y=x%w;

x=w;}

z=(a*b)/x;

disp.setText("The HCF is "+x+"\nThe LCM is "+z);}

56 | P a g e
Q24 : To create percentage calculator.

DESIGN VIEW

57 | P a g e
OUTPUT

CODING
For Calculate Button :

private void CalculateActionPerformed(java.awt.event.ActionEvent evt) {

int P= Integer.parseInt(p.getText());

int C= Integer.parseInt(c.getText());

int M= Integer.parseInt(m.getText());

int E= Integer.parseInt(e.getText());

int I= Integer.parseInt(i.getText());

double O;

O=(P+C+M+E+I)/5;

String G=null;

if (O>=90) { G="A+";}

else if(O>= 80 && O<90) {

58 | P a g e
G = "A-";}

else if(O>= 70 && O<80) {

G = "B+";}

else if(O>= 60 && O<70) {

G = "B-";}

else if(O>= 50 && O<60) {

G = "C+";}

else if(O>= 40 && O<50) {

G = "C-";}

else {

G = "You got F";}

s.s

For Clear Button :

s.setText(null);

For Exit Button :

System.exit(0);

59 | P a g e
Q25 : To create a registration for placements of job seekers.

DESIGN VIEW

60 | P a g e
OUTPUT

61 | P a g e
CODING
: For Submit Button

if(pgtcb.isSelected()==true)

gradcb.setSelected(true);

intercb.setSelected(true);

if(gradcb.isSelected()==true)

intercb.setSelected(true);

String str = null;

if(malerb.isSelected())

{ str = "Hello Mr. "+ name.getText()+" you are registered";}

else if(femalerb.isSelected())

{ str = "Hello Ms. "+ name.getText()+" you are registered";}

JOptionPane.showMessageDialog(null,str);

For Clear Button :

gradcb.setSelected(false);

intercb.setSelected(false);

pgtcb.setSelected(false);

name.setText(null);

malerb.setSelected(false);

femalerb.setSelected(false);

For Close Button :

System.exit(0);

62 | P a g e
Q26 : Design an application in which user enters his chat ID and City

DESIGN VIEW

OUTPUT

63 | P a g e
CODING
For Login Button:

String name=t1.getText();

String city=(String)c1.getSelectedItem();

l1.setText("<html>Hi "+ name +", Welcome to W3schools.net<br>How is The Weather in "+city);

64 | P a g e
Q27 : To design a simple purpose dialog through the application.

DESIGN VIEW

OUTPUT

65 | P a g e
CODING
For Show Button:

JOptionPane.showMessageDialog(null,”Merry Christmas”);

66 | P a g e
Q 28: To design that decides the eligibility of the user as per his age.

DESIGN VIEW

OUTPUT

67 | P a g e
CODING
For Check Eligibility Button:

String a = JOptionPane.showInputDialog("Enter Age");

try{

int age= Integer.parseInt(a);

if(age>=13 && age<=20)

JOptionPane.showMessageDialog(null,"Is Eligible");

else

JOptionPane.showMessageDialog(null,"Is not Eligible");}

catch(NumberFormatException e){

JOptionPane.showMessageDialog(null,"Enter age as Numeric Value");

68 | P a g e
Q 29: To create a table that can receive input of the user and also display total count of records.

DESIGN VIEW

OUTPUT

69 | P a g e
CODING
For Add row Button:

Object []x = {t1.getText(),t2.getText(),t3.getText(),t4.getText(),};

DefaultTableModel Tbl = (DefaultTableModel)tbl.getModel();

Tbl.addRow(x);

For Display Count Button:

JOptionPane.showMessageDialog(null, tbl.getRowCount());

For Classwise Count Button :

int a = tbl.getRowCount();
Object A = tbl.getValueAt(0,2);
Object val = new Object();
int cnt = 1;
String msg = new String();
int i;
for(i=1; i<a; ++i)
{val = tbl.getValueAt(i,2);
if(val.equals(A))
{cnt++;}
else {msg = msg+"Class "+tbl.getValueAt(i-1,2)+" has "+cnt+" students.\n";
cnt = 1;
A= tbl.getValueAt(i,2);}}
msg = msg+" Class "+tbl.getValueAt(i-1,2)+" has "+cnt+" students.\n";
JOptionPane.showMessageDialog(null,msg);

For Exit Button:

System.exit(0);}

70 | P a g e
Q 30: To create a table that can receive input of the user and manage an address book.

DESIGN VIEW

71 | P a g e
OUTPUT

72 | P a g e
CODING
For Add Record Button:

Object []x = {t1.getText(),t2.getText(),t3.getText(),t4.getText()};


DefaultTableModel a = (DefaultTableModel)tbl.getModel();
a.addRow(x);
int sn = Integer.parseInt(t1.getText());
t1.setText(""+(++sn));
t2.setText("");
t3.setText("");
t4.setText("");

For Clear Record Button:

t2.setText("");
t3.setText("");
t4.setText("");

For Statistics Button :

int r = tbl.getRowCount();
JOptionPane.showMessageDialog(null,"Total Records in the address in the book:"+r);

For Exit Button:

System.exit(0);}

For Search Button:

int c = Integer.parseInt(t5.getText());
int r = Integer.parseInt(t6.getText());
Object A = t6.getText();
c = c-1;
int i;
for(i=0;i<r; ++i)
{Object f = tbl.getValueAt(i,c);
if(f.equals(A))
{JOptionPane.showMessageDialog(rootPane,"Exists in Record");}
else {JOptionPane.showMessageDialog(rootPane, "Record with this value doesn't exist");}}

73 | P a g e
74 | P a g e
Output Window

Codeing:

<html><head><title>merging</title><font face="ravie" color="red" size=60>


</head>
<body bgcolor="green">
<font face="forte" color="Blue" size=30>
<table border=3 bordercolor="pink" cellspacing=10 cellpadding=10>
<tr><th colspan=4> time table </th></tr>
<tr><td rowspan=2> english </td><td>acc</td><td>bst</td><td rowspan=3>
english</td></tr>
<tr><td>ip</td><td>ip</td></tr>
<tr><td>ip</td><td>eco</td><td>eco</td></tr>
</font></body></html>

75 | P a g e
Output Window

Codeing:
<html>
<head><title> USING FORM</title>
<body bgcolor="yellow">
<font color="red">
<CENTER><H1>FREE MALL INDIA.COM</H1></CENTER>
<CENTER><H4>GET A FREE MALL INDIA! ID AND CONNECT TO PEOPLE</H4></CENTER>

<FORM ACTION="SHASHWAT@GMAIL.COM" METHOD="GET">


<H5>PERSNOL DETAILS</H5>
<label="ENTER YOUR NAME">FIRST NAME</label>
<input type="TEXT" ID="1 NAME"><BR><BR>

<label="GENDER.....">GENDER.....</label>
<input type="RADIO" NAME="GENDER" VALUE="FEMALE">FEMALE
<input type="RADIO" NAME="GENDER" VALUE="MALE">MALE<BR>
<BR><BR>
<label="COUNTRY">COUNTRY</label>
<SELECT>
<OPTION></OPTION>

76 | P a g e
<OPTION>INDIA</OPTION>
<OPTION>USA</OPTION>
<OPTION>AUSTRALIA</OPTION>
</SELECT>
<BR><BR>
<CENTER>
<label="SELECT AN ID AND PASSWORD">SELECT AN ID AND PASSWORD</label></CENTER>

<BR><BR>
<input type="CHECKBOX" NAME="PROFESSION" VALUE="EMPLOYED">EMPLOYED
<input type="CHECKBOX" NAME="PROFESSION" VALUE="UNEMPLOYED">UNEMPLOYED</BR>
<TEXTAREA ROWS=5 COL=5 NAME="COMM">
COMMENTS</TEXTAREA>
<input type="RESET" VALUE="RESET">
<input type="SUBMIT" VALUE="SUBMIT">

</FORM>

</font>

</body>

</html>

77 | P a g e
Output Window

Codeing:
<html>
<head><title>FORm</title>
<body bgcolor="yellow">
<font color="red">
<FORM ACTION="SHASHWAT@GMAIL.COM" METHOD="GET">

<label="FIRST NAME">FIRST NAME</label>


<input type="TEXT" ID="1 NAME"><BR><BR>
<label="LAST NAME">LAST NAME</label>
<input type="TEXT" ID="2 NAME"><BR><BR>

<label="E-MAIL">E-MAIL</label>

78 | P a g e
<input type="TEXT" ID="E NAME"><BR><BR>
<label="COUNTRY">COUNTRY</label>
<SELECT>
<OPTION></OPTION>
<OPTION>INDIA</OPTION>
<OPTION>USA</OPTION>
<OPTION>AUSTRALIA</OPTION>
</SELECT>
<BR><BR>
<input type="RADIO" NAME="GENDER" VALUE="FEMALE">FEMALE
<input type="RADIO" NAME="GENDER" VALUE="MALE">MALE</BR>
<BR><BR>
<input type="CHECKBOX" NAME="PROFESSION" VALUE="EMPLOYED">EMPLOYED
<input type="CHECKBOX" NAME="PROFESSION" VALUE="UNEMPLOYED">UNEMPLOYED</BR>
<TEXTAREA ROWS=5 COL=5 NAME="COMM">
COMMENTS</TEXTAREA>
<input type="RESET" VALUE="RESET">
<input type="SUBMIT" VALUE="SUBMIT">

</FORM>

</font>

</body>

</html>

79 | P a g e
80 | P a g e
Question1: Consider the table empl given below and run the following Queries.

Queries:
1. List the details of those employees whose annual salary is between 25000 and 40000.
SELECT * FROM empl where sal BETWEEN 2500 AND 4000;

2. Display the name of employees whose name contains ‘A’ as the 4 alphabet.
th

SELECT ename FROM empl WHERE ename like ‘___a%’;

81 | P a g e
3. Display Name, Job and Salary of employees who do not have a manager.

SELECT ename, job, sal FROM empl WHERE mgr IS NULL;

4. Display Name, Salary and salary added with commision.

SELECT ename, sal, sal+comm FROM empl;

5. Display details of employees who earn more commission than their salaries.

SELECT * FROM empl WHERE comm>sal;

82 | P a g e
Question 2 : Consider the table EMPLOYEE given below and run the following Queries.

Queries:
1. For record with ID=4 update record with last Name, User ID and Salary.

UPDATE employe SET Last_Name=’SAHUKAR’,User_ID=’skar’,Salary=9000 WHERE ID=4;

2. Modify the last name of employees to Gautam where salary<5000.

UPDATE employe SET Last_Name=’Gautam’ WHERE Salary<5000;

83 | P a g e
3. Add column Email of data type VARCHAR to the table.
ALTER TABLE employe ADD(Email VARCHAR(30));

4. Delete the employee record having first name as SIDDHARTH.

DELETE FROM employe WHERE First_Name=’SIDDHARTH’;

5. Modify the salary and increases it by 1000, for all who get salary less than 5000.

UPDATE employe SET Salary =Salary+1000 WHERE Salary<5000;

84 | P a g e
85 | P a g e

You might also like