You are on page 1of 29
THIS IS TO CERTIFY THAT RIGZEN YANGDOL OF CLASS XII OF LITTLE FAIY PUBLIC SCHOOL, HUDSON

THIS IS TO CERTIFY THAT RIGZEN YANGDOL OF CLASS XII OF LITTLE FAIY PUBLIC SCHOOL, HUDSON LANE, NEW DELHI HAS COMPLETED THIS PROJECT UNDER MY SUPERVISION. SHE HAS AKE PROPER ARE AND SHOWN ATST SINCERTY IN COMPLETION THIS PROJECT.

I CERTIFY THAT THIS PROJECTIS UPTO MY EXPECTATIONAND AS PER THE GUIDANCE AND GUIDELINES.

MRS. PREETI KAPOOR (SIGNATURE)

I would like to convey my heartful thanks to Mrs. Preeti Kapoor, my informatic practices teacher

I would like to convey my heartful thanks to Mrs. Preeti Kapoor, my informatic practices teacher who guided me through the project and also gave valuable suggestions and guidance for completion of the project. She helped me to nderstand and remember important details of the project that I would have otherwise lost. My project has been a success only because of the guidance.

Rigzen Yangdol

(Little

Fairy Public School)

1. Make a GUI application that performs Calculate and Exit. Calculate and Exit buttons should get activated.

1. Make a GUI application that performs Calculate and Exit. Calculate and Exit buttons should get

private void calbtnActionPerformed(java.awt.event.ActionEvent evt) { String name=tf1.getText(); int roll=Integer.parseInt(tf2.getText()); float eng,eco,bs,acc,ip,per,total;

eng=Float.parseFloat(tf3.getText());

eco=Float.parseFloat(tf4.getText());

acc=Float.parseFloat(tf5.getText());

ip=Float.parseFloat(tf6.getText());

bs=Float.parseFloat(tf7.getText());

total=eng+eco+acc+ip+bs; tf8.setText("Your total marks is="+total);

per=total/5;

tf9.setText("Your percentage is="+per);

if(per>=90)

{ tf10.setText("Your Grade is A+"); } else if(per>=80&&per<89) { tf10.setText("Your Grade is B"); } else if(per>=70&&per<79)

{ tf10.setText("Your Grade is C");} else if(per>=60&&per<69) { tf10.setText("Your Grade is D"); } else { tf10.setText("Your Grade is E");

} private void exitbtnActionPerformed(java.awt.event.ActionEvent evt) {

}

System.exit(0) }

2.Make a GUI application that performs Submission of Record into text Field . Submit, Clear and Exit buttons should get activated.

2. Make a GUI application that performs Submission of Record into text Field . Submit, Clear

private void subbtnActionPerformed(java.awt.event.ActionEvent evt) { String nm,hn,str,ct,sta;

nm=tf1.getText();

ta.append("name:"+nm);

hn=tf2.getText();

ta.append("\nhouse no:"+hn);

str=tf4.getText();

ta.append("\nstreet:"+str);

ct=tf5.getText();

ta.append("\ncity:"+ct);

sta=tf6.getText();

ta.append("\nstate:"+sta); } private void taFocusGained(java.awt.event.FocusEvent evt) { ta.selectAll();

}

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

tf1.setText(" ");

tf2.setText(" ");

tf3.setText(" ");

tf4.setText(" ");

tf5.setText(" ");

tf6.setText(" ");

ta.setText(" ");

}

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

System.exit(0);

}

3.Make a GUI application that performs Calculation of cost price and selling price . Calculate and Clear buttons should get activated.

tf1.setText(" "); tf2.setText(" "); tf3.setText(" "); tf4.setText(" "); tf5.setText(" "); tf6.setText(" "); ta.setText(" "); } private

private void calbtnActionPerformed(java.awt.event.ActionEvent evt) { float cost,selling,p,l;

cost=Float.parseFloat(tf1.getText());

selling=Float.parseFloat(tf2.getText());

if(selling>cost)

{

p=selling-cost;

lb3.setText("profit="+p);

}

else

{

l=cost-selling;

lb3.setText("Loss="+l);

} private void clearbtnActionPerformed(java.awt.event.ActionEvent evt) {

}

tf1.setText(" ");

tf2.setText(" ");

lb3.setText(" ");

}

4.Make a GUI application that performs Replace of the with A . Ok button should get activated.

if(selling>cost) { p=selling-cost; lb3.setText("profit="+p); } else { l=cost-selling; lb3.setText("Loss="+l); } private void clearbtnActionPerformed(java.awt.event.ActionEvent evt) { }

private void okbtnActionPerformed(java.awt.event.ActionEvent evt) { String str;

str=tf1.getText();

str=str.replace("the","a"); lb2.setText("String replace with a="+str);

}

5.Make a GUI application that performs Smallest Number among 3 number . Ok and clear buttons should get activated.

str=str.replace("the","a"); lb2.setText("String replace with a="+str); } 5.Make a GUI application that performs Smallest Number among 3

private void okActionPerformed(java.awt.event.ActionEvent evt) { int a,b,c;

a=Integer.parseInt(tf1.getText());

b=Integer.parseInt(tf2.getText());

c=Integer.parseInt(tf3.getText());

if(a<c&&a<b) { lb4.setText("Number1 is smaller="+a); } else if(b<a&&b<c) { lb4.setText("Number2 is smaller="+b); } else { lb4.setText("Number3 is smaller="+c);

}

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

tf1.setText(" ");

tf2.setText(" ");

tf3.setText(" ");

lb4.setText(" ");

}

5. Make a GUI application that performs Area and Perimeter of Rectangle . Ok button should get activated.

tf1.setText(" "); tf2.setText(" "); tf3.setText(" "); lb4.setText(" "); } 5. Make a GUI application that performs

private void okbtnActionPerformed(java.awt.event.ActionEvent evt) { int a,b,area,parimeter;

a=Integer.parseInt(tf1.getText());

b=Integer.parseInt(tf2.getText());

area=a*b;

parimeter=2*(a+b);

if(rb1.isSelected())

{ lb4.setText("Area is="+area) }

else { lb4.setText("Parimeter is="+parimeter); }

}

6.Make a GUI application that performs Discount and Net Payment after inserting Amount . Calculate button should get activated.

else { lb4.setText("Parimeter is="+parimeter); } } 6.Make a GUI application that performs Discount and Net Payment

private void calbtnActionPerformed(java.awt.event.ActionEvent evt) { int amt; float dis,netp;

amt=Integer.parseInt(tf1.getText());

if(amt>=10000)

{

dis=amt*20/100;netp=amt-dis;

} else if(amt>7000&&amt<10000)

{

dis=amt*15/100;

netp=amt-dis; } else if(amt>5000&&amt<7000)

{dis=amt*10/100;

netp=amt-dis; } else if(amt>2000&&amt<5000) {

dis=amt*5/100;

netp=amt-dis; } else {

dis=amt*2/100;

netp=amt-dis; }

lb2.setText(""+netp);

lb3.setText(""+dis);

}

7.Make a GUI application that perform Basic Entry Form . Submit and Clear buttons should get activated.

private void subbtnActionPerformed(java.awt.event.ActionEvent evt) { if(ck1.isSelected()==true) { ck2.setSelected(true); ck3.setSelected(true);} if(ck2.isSelected()==true) { ck3.setSelected(true); } private void tf1FocusLost(java.awt.event.FocusEvent

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

if(ck1.isSelected()==true)

{ ck2.setSelected(true);

ck3.setSelected(true);}

if(ck2.isSelected()==true)

{ ck3.setSelected(true);

} private void tf1FocusLost(java.awt.event.FocusEvent evt) { String name;

}

name=tf1.getText().toUpperCase();

tf1.setText(""+name);

}

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

ck1.setSelected(false);

ck2.setSelected(false);

ck3.setSelected(false);

rb1.setSelected(true);

rb2.setSelected(true);

tf1.setText(" ");

}

8.Make a GUI application that perform Replace of character and Append these character .Replace and Append buttons should get activated.

8.Make a GUI application that perform Replace of character and Append these character .Replace and Append

private void tf1FocusLost(java.awt.event.FocusEvent evt) { String str;

str=tf1.getText();

if(str.endsWith("ok"))

{

repbtn.setEnabled(true);

appbtn.setEnabled(true);

}

else

{

repbtn.setEnabled(false); appbtn.setEnabled(false); jOptionPane.showMessageDialog(null,"The input string must end with 'ok'.");

tf1.setText(str+"ok");

}

} private void repbtnActionPerformed(java.awt.event.ActionEvent evt) { String str;

str=tf1.getText();

str=str.replace('h','a'); str=str.replace('u','e'); str=str.replace('y','i');

lb3.setText(str);

} private void appbtnActionPerformed(java.awt.event.ActionEvent evt) { String st;

st=tf2.getText();

StringBuffer sb=new StringBuffer(tf2.getText()); sb.append("str");

lb3.setText(sb.toString());

} private void CLRBTNActionPerformed(java.awt.event.ActionEvent evt) { tf1.setText(" "); tf2.setText(" "); lb3.setText(" ");}

Q9 Design an application that does not have any text field or any other control to obtain input or show output ; it just has a button ,yet it can obtain number of days from the user and display equivalent years, months and days?

import javax.swing.JOptionPane; private void jbutton1(java.awt.event.FocusEvent evt) String days=JOptionPane.showInputDialog("ENTER NUMBER OF DAYS"); { int ds=Integer.parseInt(days); int d=0,m=0,y=0;
import javax.swing.JOptionPane; private void jbutton1(java.awt.event.FocusEvent evt) String days=JOptionPane.showInputDialog("ENTER NUMBER OF DAYS"); { int ds=Integer.parseInt(days); int d=0,m=0,y=0;

import javax.swing.JOptionPane;

private void jbutton1(java.awt.event.FocusEvent evt)

String days=JOptionPane.showInputDialog("ENTER NUMBER OF DAYS");

{

int ds=Integer.parseInt(days); int d=0,m=0,y=0;

y=ds/365;

m=(ds %365)/30;

d=(ds%365)%30;

String msg = " "+ds+" days are equivalent to \n " + y + " years " + m + "

months " + d + " days approx. "; JOptionPane.showMessageDialog(null,msg);

}

Q-10 Create a java GUI application that lets create an address book. the detail to added in address book are: Name , Email ID , Phone .

be

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { Object[] oary = { snoTF.getText(), namTF.getText(), emlTF.getText(), phoTF.getText()}; DefaultTableModel tm =
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { Object[] oary = { snoTF.getText(), namTF.getText(), emlTF.getText(), phoTF.getText()}; DefaultTableModel tm =

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { Object[] oary = { snoTF.getText(), namTF.getText(), emlTF.getText(), phoTF.getText()}; DefaultTableModel tm = (DefaultTableModel) jTable1.getModel(); tm.addRow(oary); int sn = Integer.parseInt(snoTF.getText()); snoTF.setText("" + ((++sn))); namTF.setText(""); emlTF.setText(""); phoTF.setText("");

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { namTF.setText(""); emlTF.setText("");

phoTF.setText("");

}

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

System.exit(0);

} private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)

{

int r = jTable1.getRowCount();

JOptionPane.showMessageDialog(null, "TOTAL RECORD IN ADDRESS BOOK ; " + r); }

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { snoTF.setText(""); namTF.setText(""); emlTF.setText(""); phoTF.setText("");

}

11.Create a java GUI application that performs Update and Delete operations on a Database. Update and delete buttons should get activated only if the record based on provided search value is found in the Database.

import java.sql.*; import javax.swing.table.DefaultTableModel; private void loadActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName ("java.sql.DriverManager"); Connection con =(Connection)

import java.sql.*; import javax.swing.table.DefaultTableModel; private void loadActionPerformed(java.awt.event.ActionEvent evt)

{

try

{

Class.forName ("java.sql.DriverManager"); Connection con =(Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","");

Statement stmt =(Statement) con.createStatement(); String query ="SELECT * FROM department WHERE deptno='"+TF1.getText()

+"';";

ResultSet rs= stmt.executeQuery(query);

if (rs.next())

{

String dno = rs.getString("deptno");

String dname = rs.getString("deptname"); String loc = rs.getString("location");

TF2.setText(dname);

TF3.setText(loc);

update.setEnabled(true);

delete.setEnabled(true);

}

 

else

{

}

jOptionPane1.showMessageDialog(null,"no such record found." ); }

catch(Exception e) { jOptionPane1.showMessageDialog(null,e.getMessage() ); }

}

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

int ans = jOptionPane1.showConfirmDialog(null,"surely want to update records.");

if (ans==jOptionPane1.YES_OPTION) {

try { Class.forName ("java.sql.DriverManager"); Connection con =(Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","");

stmt = con.createStatement();

String query ="UPDATE department SET deptname ='"+TF2.getText() +"',location='"+TF3.getText()+"' WHERE deptno ='"+TF1.getText()+"';";

stmt.executeUpdate(query); jOptionPane1.showMessageDialog(null,"Record successfully updated.");

}

} catch(Exception e) {

}

jOptionPane1.showMessageDialog(null, e.getMessage()); }

private void deleteActionPerformed(java.awt.event.ActionEvent evt) { int ans = jOptionPane1.showConfirmDialog(null,"wann to delete the records?"); if (ans==jOptionPane1.YES_OPTION) {

try { Class.forName ("java.sql.DriverManager"); Connection con =(Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","");

stmt = con.createStatement(); String query ="Delete from department WHERE deptno ='"+TF1.getText()

+"';";

stmt.executeUpdate(query); jOptionPane1.showMessageDialog(null,"Record deleted.?");

} catch(Exception e) {

jOptionPane1.showMessageDialog(null, e.getMessage());

} private void addbtnActionPerformed(java.awt.event.ActionEvent evt) {

}

}

String deptno, dname, loc;

deptno=TF1.getText();

dname = TF2.getText(); loc= TF3.getText();

try

{ Class.forName ("java.sql.DriverManager"); Connection con =(Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","");

stmt = con.createStatement();

String query ="insert into department values('"+deptno+"','"+dname+"','"+loc+"');";

stmt.executeUpdate(query); jOptionPane1.showMessageDialog(null,"Record deleted.?");

} catch(Exception e) {

}

jOptionPane1.showMessageDialog(null, e.getMessage()); }

12.Create a java GUI application that performs search operations on a Database. Search button should get activated only if the record based on provided search value is found in the Database.

{ Class.forName ("java.sql.DriverManager"); Connection con =(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root",""); stmt = con.createStatement(); String query ="insert into department values('"+deptno+"','"+dname+"','"+loc+"');";

import java.sql.*; private void searchActionPerformed(java.awt.event.ActionEvent evt) { String mobile=tf2.getText();

if (mobile.isEmpty()) {

tf1.setText(" "); tf2.setText(" "); jOptionPane.showMessageDialog(null," enter mobile number" );

}

else

{

try

{ Class.forName("java.sql.DriverManager"); Connection con=(Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","");

Statement stmt=(Statement)con.createStatement(); String query ="SELECT NAME,EMAIL FROM contact WHERE MOBILE='"+mobile+"';"; ResultSet rs = stmt.executeQuery(query); if (rs.next()) {

String name = rs.getString("name"); String email = rs.getString("email");

tf1.setText(name);

tf3.setText(email);

} else jOptionPane.showMessageDialog(this,"Sorry! no such records"); } catch(Exception e) {

}

jOptionPane.showMessageDialog(this,e.getMessage()); } }

13.Create a java GUI application that performs Personal contact operations on a Database.

Refresh Data button should get activated only if the record based on provided search value is found in the Database.

Refresh Data button should get activated only if the record based on provided search value is

package javaapplication8; import javax.swing.table.DefaultTableModel; import java.sql.*; private void refreshActionPerformed(java.awt.event.ActionEvent evt) { DefaultTableModel model = (DefaultTableModel)jTable1.getModel(); try {

Class.forName("java.sql.DriverManager") ; Connection Con = (Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","");

Statement stmt = (Statement)Con.createStatement(); String Tname; if (personalrb.isSelected()) {

Tname ="Contact" ;

}

else

{

Tname = "Offical";

}

String Query= "Select * From "+Tname+""; ResultSet rs = stmt.executeQuery(Query); while(rs.next()) {

}

String Name = rs.getString("name"); String Mobile = rs.getString("mobile"); String Email = rs.getString("email"); model.addRow(new Object[]{Name, Mobile,Email}); } catch ( Exception e)

{

 

jOptionPane1.showMessageDialog(null,e.getMessage());

}

} private void ResettablebtnActionPerformed(java.awt.event.ActionEvent evt) { DefaultTableModel model = (DefaultTableModel)jTable1.getModel(); int rows= model.getRowCount(); if (rows>0) {

for(int i=0;i<rows;i++) {

model.removeRow(0);

}

}

}

Q-14 Design a data connectivity that fetches data from EMPL table?

import javax.swing.table.*; import java.sql.*; import javax.swing.*; private void { DefaultTableModel model=(DefaultTableModel)jTable1.getModel(); int rows = model.getRowCount(); if

import javax.swing.table.*; import java.sql.*; import javax.swing.*;

private void

{

DefaultTableModel model=(DefaultTableModel)jTable1.getModel(); int rows = model.getRowCount(); if (rows>0){ for (int i=0;i<rows;i++){

model.removeRow(0);

} try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection

}

con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/test",

"root",""); Statement stmt=con.createStatement(); String query = "SELECT * FROM TEACHER"; ResultSet rs=stmt.executeQuery(query); while (rs.next()) { String ntNo=rs.getString("TNO"); String ntName=rs.getString("TNAME"); String ntAddress=rs.getString("TADDRESS"); String ntSalary=rs.getString("TSALARY"); String ndept_no=rs.getString("DEPT_NO");

String ndoj=rs.getString("DOJ");

System.out.println(ntNo+"1"+ntName);

model.addRow(new Oject[]{ntNo,ntName,ntAddress,ntSalary,ndept_no,ndoj }); } }

catch (Exception e) { JOptionPane.showMessageDialog(this,e.getMessage()); }

}

private void Exitbtn ActionPerformed(java.awt.event.ActionEvent evt) {

System.exit(0);

}

<a href=WWW.GOOGLE.COM WWW.CBSE.COM SUMITA ARORA FOR CLASS XII " id="pdf-obj-28-3" src="pdf-obj-28-3.jpg">
  • SUMITA ARORA FOR CLASS XII