Académique Documents
Professionnel Documents
Culture Documents
S.N
o
Program Description
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Date
Signature
Q2) Create a java desktop application to your name & Address in the
message box. Using two input boxes enter both name and address & also
show Another message window.
String a=jTextField1.getText();
String b=jTextField2.getText();
JOptionPane.showMessageDialog(this,"Name: "+a+"\n"+"Address: "+b);
// ADD BUTTON
tf3.setEditable(false);
float a=Float.parseFloat(tf1.getText());
float b=Float.parseFloat(tf2.getText());
float c=a+b;
tf3.setText(String.valueOf(c));
//SUBTRACT BUTTON
tf3.setEditable(false);
float a=Float.parseFloat(tf1.getText());
float b=Float.parseFloat(tf2.getText());
float c=a-b;
tf3.setText(String.valueOf(c));
//MULTIPLY BUTTON
tf3.setEditable(false);
float a=Float.parseFloat(tf1.getText());
float b=Float.parseFloat(tf2.getText());
float c=a*b;
tf3.setText(String.valueOf(c));
//DIVIDE BUTTON
tf3.setEditable(false);
float a=Float.parseFloat(tf1.getText());
float b=Float.parseFloat(tf2.getText());
float c=a/b;
tf3.setText(String.valueOf(c));
Q4) Accept cost price & sale price of product calculate the amount of
profit or loss & display the amount along with appropiate message.
float cp=Float.parseFloat(tf1.getText());
float sp=Float.parseFloat(tf2.getText());
float total=sp-cp;
if(total>0)
c.setText("you have a profit of Rs"+total);
else if(total<0)
c.setText("you have a loss of Rs"+total);
else
c.setText("you have no profit and no loss");
//CALCULATE BUTTON
float p=Float.parseFloat(pamt.getText());
float r=Float.parseFloat(rate.getText());
float t=Float.parseFloat(time.getText());
float interest=(p*r*t)/100;
if(intrst.isSelected())
{lbl.setText("your interest amount is "+interest);
}if(amt.isSelected())
{ float amount=interest+p;
lbl.setText("your amount is "+amount);
}
//CLEAR BUTTON
pamt.setText(" ");
rate.setText(" ");
time.setText(" ");
//EXIT BUTTON
System.exit(0);
int fnum=Integer.parseInt(tf1.getText());
int snum=Integer.parseInt(tf2.getText());
int tnum=Integer.parseInt(tf3.getText());
if(fnum>snum&&fnum>tnum)
lbl.setText("First number is greater");
else if(snum>fnum&&snum>tnum)
lbl.setText("Second number is greater");
else if(tnum>fnum&&tnum>snum)
lbl.setText("third number is greater");
else if(fnum==snum&&fnum>tnum)
lbl.setText("First and second number are greater");
else if(snum==tnum&&snum>fnum)
lbl.setText("Second and third are greater");
else if(tnum==fnum&&tnum>snum)
lbl.setText("First and third number are greater");
else if(fnum==snum&&snum==tnum&&fnum==tnum)
lbl.setText("All are equal");
Q7) Develop a GUI application to enter the month number & display
respective month name and days in that month.
month.setEditable(false);
days.setEditable(false);
int a=Integer.parseInt(tf1.getText());
switch(a){
case 1:month.setText("January");
break;case 2:month.setText("February");
break;case 3:month.setText("March");
break;case 4:month.setText("April");
break;case 5:month.setText("May");
break;case 6:month.setText("June");
break;case 7:month.setText("July");
break;case 8:month.setText("August");
break;case 9:month.setText("September");
break;case 10:month.setText("October");
break;case 11:month.setText("November");
break;case 12:month.setText("December");break;
default:month.setText("please insert right number");
}if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
days.setText("31");
else if(a==4||a==6||a==9||a==11)
days.setText("30");
else if(a==2)
days.setText("28");
int per=Integer.parseInt(tf1.getText());
if(per>=90&&per<=100)
lbl.setText("A++");
else if(per>=80&&per<90)
lbl.setText("A+");
else if(per>=75&&per<80)
lbl.setText("A");
else if(per>=60&&per<75)
lbl.setText("B");
else if(per>=50&&per<60)
lbl.setText("C");
else if(per>=40&&per<50)
lbl.setText("D");
else if(per>=0&&per<40)
lbl.setText("E");
else
lbl.setText("please enter correct value");
int color=cb.getSelectedIndex();
if(color==0){
lbl.setForeground(Color.red);
}if(color==1){
lbl.setForeground(Color.green);
}if(color==2){
lbl.setForeground(Color.blue);
}if(color==3){
lbl.setForeground(Color.white);
}if(color==4){
lbl.setForeground(Color.black);
}if(color==5){
lbl.setForeground(Color.yellow);}
Q10) NDPL generate computerised bills for its customer every month.
double charge=0;
int a=Integer.parseInt(tf.getText());
if(r.isSelected()){
c.setEnabled(true);
c1.setEnabled(true);
if(c.isSelected())
{charge=a*5.40;}
else if(c1.isSelected())
{ charge=a*4.92;}
}
if(r1.isSelected()){
c.setEnabled(true);
c1.setEnabled(true);
if(c.isSelected())
{charge=a*1.55;}
else if(c1.isSelected())
{charge=a*9.84;}
}
if(r2.isSelected()){
c.setEnabled(true);
c1.setEnabled(true);
if(c.isSelected())
{charge=a*5.05;}
else
if(c1.isSelected())
{charge=a*4.40;}
}
if(r3.isSelected()){
c.setEnabled(false);
c1.setEnabled(false);
if(a<=200)
charge=(a*2.45);
else if(a<=400)
charge=((a-200)*3.95)+490;
else if(a>400)
charge=((a-400)*4.65)+1280;
}
int num=Integer.parseInt(tf1.getText());
int i,n=1,s=1;
jta.append(n+" ");
for(i=1;i<=num;i=n+s)
{jta1.append(i+" ");
n=s;
s=i;
}
Q12. Create a Java Application to input any number and print its
reverse using while loop and print whether the number is palindrome or
not.
tf2.setEditable(false);
int a=Integer.parseInt(tf1.getText());
int b=0,c=a;
while(a!=0){
b=(b*10)+(a%10);
a=a/10;
tf2.setText(" "+b);
}
if(c==b)lbl.setText("it is a palindrome ");
else
lbl.setText("It is not a palindrome ");
tf2.setEditable(false);
tf3.setEditable(false);
float a=Float.parseFloat(tf1.getText());
float c=0,d;
int b=cb.getSelectedIndex();
if(b==0)
{c=(float) (a*0.1);}
if(b==1){
c= a*0.05F;
} if(b==2){
c=a*0.07F;}
tf2.setText(""+c);
d=c+a;
tf3.setText(""+d);
// Add Player
String name=tf.getText();
DefaultListModel dlm=(DefaultListModel)lst.getModel();
dlm.add(0, name);
lst.setModel(dlm);
// Remove Player
int index;
DefaultListModel dlm=(DefaultListModel)lst.getModel();
index=lst.getSelectedIndex();
dlm.remove(index);
lst.setModel(dlm);
//Clear All Names
DefaultListModel dlm=(DefaultListModel)lst.getModel();
dlm.removeAllElements();
lst.setModel(dlm);
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/school","root","mujeeb");
Statement stmt=null;
ResultSet rs=null;
stmt=con.createStatement();
String address=tf2.getText();
float Sal=Float.parseFloat(tf3.getText());
String dept=tf4.getText();
String date=tf5.getText();
con.close();
stmt.close();
rs.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(this,e.getMessage());
}
try{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/school","root","mujeeb");
Statement stmt=null;
ResultSet rs=null;
stmt=con.createStatement();
con.close();
stmt.close();
rs.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(this,e.getMessage());