Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
37 views

Java Programing

The document contains code snippets from 10 Java programs. The programs cover topics like addition, subtraction, multiplication and division operations; school fee calculation; bank interest calculation; scoreboard for games; login validation; hotel room booking; multiple choice quiz; and marks calculation. The code shows how to parse input values, perform calculations, and set output texts or icons using Java GUI components and event handlers.

Uploaded by

max mishra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Java Programing

The document contains code snippets from 10 Java programs. The programs cover topics like addition, subtraction, multiplication and division operations; school fee calculation; bank interest calculation; scoreboard for games; login validation; hotel room booking; multiple choice quiz; and marks calculation. The code shows how to parse input values, perform calculations, and set output texts or icons using Java GUI components and event handlers.

Uploaded by

max mishra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

JAVA PROGRAMING

PROGRAM-1:-addition-

CODE:-
private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)
{
int a=Integer.parseInt (t1.getText());
int b=Integer.parseInt (t2.getText ());
int c=a+b;
t3.setText (""+c);
}
private void jButton4ActionPerformed (java.awt.event.ActionEvent evt)
{
int a=Integer.parseInt (t1.getText ());
int b=Integer.parseInt (t2.getText ());
int c=a/b;
t3.setText (""+c);
}
private void jButton3ActionPerformed (java.awt.event.ActionEvent evt)
{
int a=Integer.parseInt (t1.getText ());
int b=Integer.parseInt (t2.getText ());
int c=a*b;
t3.setText (""+c);
}

private void jButton2ActionPerformed (java.awt.event.ActionEvent evt)


{
int a=Integer.parseInt (t1.getText ());
int b=Integer.parseInt (t2.getText ());
int c=a-b;
t3.setText (""+c);
}

private void jButton5ActionPerformed (java.awt.event.ActionEvent evt)


{
System. exit(0);
} `
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt)
{
t1.setText("");
t2.setText("");
t3.setText("")
}

PROGRAM-2:- ccs public school

CODE:-
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)
{
int fee=0,tot;
if (radcom.isSelected())
fee=2500;
else if (radart.isSelected())
fee=2000;
else if (radmed.isSelected())
fee=2900;
else if (radnon.isSelected())
fee=2800;
tot=fee;
jTextField3.setText(""+tot);
if(ch1.isSelected())
tot=tot+200;
jTextField3.setText(""+tot);

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)


{
addno.setText("");
cadname.setText("");
jTextField3.setText("");
}

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


{
System. exit(0);
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)


{
addno.setEditable(false);
cadname.setEditable(false);
}

PROGRAM-3:- icici bank


CODE:-
int p,r,t,i,a;
p=Integer.parseInt(t1.getText());
t=Integer.parseInt(t3.getText());
r=0;
if(r1.isSelected()){
if(t<1)r=10;
else if (t>=1 && t<=5) r=12;
else if (t>5) r=15;
if(r2.isSelected()){
if(t<=2)r=11;
else if(t>2 && t<=7) r=12
else if(t>7) r=15;
}
if (chk1.isSelected()){
r=r+2;
}
i=p*r*t/100;
t4.setText(""+i);
a=p+i;
t5.setText(""+a);
}
}

Program-4:- score board-


Code:-
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
{
String v1=t1.getText();
int ga=Integer.parseInt(v1);
ga=ga+1;
t1.setText(""+ga);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)
{
String v1=t2.getText ();
int ga=Integer.parseInt(v1);
ga=ga+1;
t2.setText(""+ga);
}
private void declresActionPerformed(java.awt.event.ActionEvent evt)
{
String v1=t1.getText();
int ga=Integer.parseInt(v1);
String v2=t2.getText();
int gb=Integer.parseInt(v2);
String res=(ga>gb? "Team A wins":(ga<gb)?"Team b win":"Draw" );
r1.setText(res);
}

Program-5:-delete record-
code:-
String pd=new String(pwd1.getPassword());
if(pd.equals("007")){
this.setVisible(false);
new Details().setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"Invalid Password");
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)


{
System. exit(0);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)
{
us1.setText("");
pwd1.setText("");

program-6:-hotel management-

Code-
int a,b,c,d,e,f;
a=Integer.parseInt(t1.getText());
b=Integer.parseInt(t2.getText());
c=Integer.parseInt(t3.getText());
d=Integer.parseInt(t4.getText());
e=Integer.parseInt(t5.getText());
f=Integer.parseInt(t6.getText());
if(one.isSelected()){
amt.setText("2000");
}
if(two.isSelected()){
amt.setText("4000");
}
if(single.isSelected()){
amt.setText("1000");
}
if(dou.isSelected()){
amt.setText("2000");
}

Program-7:- shiksha vidyalaya-


Code:-
int score=0;
if(chk1.isSelected()){
t3.setText(""+10);
score=score+10;
}
if(chk2.isSelected()){
t4.setText(""+10);
score=score+10;
}
if(chk3.isSelected()){
t5.setText(""+10);
score=score+10;
}
t6.setText(""+score);
clear:-
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
chk1.setSelected(false);
chk2.setSelected(false);
chk3.setSelected(false);
program:-8- 7 wonders-

Code:-
private void b6ActionPerformed(java.awt.event.ActionEvent evt)
{
ta1.setText("");
t1.setIcon(new ImageIcon("E:\ravinder\220px-Cristo_Redentor_-
_Rio_de_Janeiro,_Brasil.jpg"));
ta1.append("Christ the Redeemer (Portuguese is an Art Deco.");
}
private void b1ActionPerformed(java.awt.event.ActionEvent evt) {
ta1.setText("");
t1.setIcon(new ImageIcon("E:\\ravinder\\index.jpg"));
ta1.append("Tajmahal was built by shahjhan in Agra");
}
private void b2ActionPerformed(java.awt.event.ActionEvent evt) {
ta1.setText("");
t1.setIcon(new ImageIcon("E:\\ravinder\\ffvgm.jpg"));
ta1.append("Great wall of china is situated in China")
}
private void b3ActionPerformed(java.awt.event.ActionEvent evt) {
ta1.setText("");
t1.setIcon(new ImageIcon("E:\\ravinder\\wergter.jpg"));
ta1.append("Petra originally known to the Nabataea’s as Ramus, is a
historical and archaeological city in southern Jordan.");
}
private void b4ActionPerformed(java.awt.event.ActionEvent evt) {
ta1.setText("");
t1.setIcon(new ImageIcon("E:\\ravinder\\index.jpg"));
ta1.append("Machu Picchu is a 15th-century Inca citadel situated
on a mountain ridge 2,430 meters (7,970 ft.) above sea level.");
}
private void b5ActionPerformed(java.awt.event.ActionEvent evt) {
ta1.setText("");
t1.setIcon(new ImageIcon("E:\\ravinder\\images.jpg"));
ta1.append("The Great Pyramid of Giza is the oldest and largest of
the three pyramids in the Giza pyramid complex bordering what is
now El Giza.");
}
private void b7ActionPerformed(java.awt.event.ActionEvent evt) {
ta1.setText("");
t1.setIcon(new ImageIcon("E:\\ravinder\\index.jpg"));
ta1.append("Tajmahal was built by shahjhan in Agra");

program:-9-simple interest-
Code:-
int p,r,t,i,a;
p=Integer.parseInt(t1.getText());
r=Integer.parseInt(t2.getText());
t=Integer.parseInt(t3.getText());
i=p*r*t/100;
t4.setText(""+i);
a=p+i;
t5.setText(""+a);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
}

Program:-10-marks calculator-

Code:-
int sum,phy,che,maths;
String n;
n=(String)t4.getText();
phy=Integer.parseInt(t1.getText());
che=Integer.parseInt(t2.getText());
maths=Integer.parseInt(t3.getText());
sum=phy+che+maths;
t.append("name:"+n+'\n');
t.append("marks:"+sum+'\n');

if(sum>=180&&sum<=300){
t.append("eligible");
}
else{
t.append("not eligible");
}

You might also like