Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Practices
Working with NetBeans
Programmes
1
1. System Exit
Objective: To terminate the programme successfully.
Design:
Coding:
On the click of jButton1:
System.exit(0);
2. Wish Me
Objective: To make a program to wish us.
Design:
Coding:
JOptionPane.showMessageDialog(null,"WISHING YOU A
GREAT DAY!");
3. Morning Or Evening
Objective: To make an application to greet us good morning or
good evening.
Design:
2
Coding:
On the click of jButton1:
JOptionPane.showMessageDialog(null,"Good Morning");
Coding:
On the click of jButton1:
jTextField1.setText("Good Morning");
3
On the click of jButton3:
System.exit(0);
5. Personalized Wisher
Objective: To show a message with the name in the input.
Design:
Coding:
On the click of jButton1:
jTextfield2.setText(Good Morning + jTextField1.getText());
4
Design:
Coding:
On the click of jRadioButton1:
jTextField2.setText("Mr. " + jTextField1.getText());
Coding:
On the click of jButton1:
jTextArea1.setText(jTextfield1.getText() + and +
jTextField2.getText() + are true friends. \n + A true
5
friend encourages you to live your dreams, supports you
towards your goal.);
8. Password Field
Objective: To show the working of a password field.
Design:
Coding:
On the click of jButton1:
JOptionPane.showMessageDialog(null,jtextField.getText()
+ Logged In Demo Version successfully \n + (Password
ignored will be checked later);
9. Dozens
Objective: To calculate the amount to be paid in dozen.
Design:
6
Coding:
On the click of jButton1:
jTextField2.setText(Integer.toString(12*Integer.parseInt(jTe
xField1.getText()));
Coding:
On the click of jButton1:
jTextField3.setText(Integer.toString(Integer.parseInt(jTextFi
eld1.getText())*Integer.parseInt(jTextField2.getText())));
7
On the click of jButton2:
System.exit(0);
Coding:
On the click of jButton1:
jTextField4.setText(Integer.toString(Integer.parseInt(jTextFi
eld1.getText())
+Integer.toString(Integer.parseInt(jTextField2.getText())
+Integer.toStirng(Integer.parseInt(jTextField3.getText())));
8
Coding:
On the click of jButton1:
Char star;
star = *;
jTextField2.setText(star+jTextfield1.getText()+star);
9
Coding:
On the click of jButton1:
int a,b,c;
double f;
a=Integer.parseInt(jTextField1.getText());
b=Integer.parseInt(jTextField2.getText());
c=a+b;
jTextField3.setText(Integer.toString(c));
10
14. Simple Interest Calculator
Objective: To make a simple interest calculator
Design:
Coding:
On the click of jButton1:
double p,r,si;
byte t;
p=Double.parseDouble(jTextField1.getText());
r=Double.parseDouble(jTextField2.getText());
t=Byte.parseByte(jTextField3.getText());
si=(p*r*t)/100;
jTextField4.setText(Double.toString(si));
11
Coding:
On the click of jRadiobutton1:
jLabel1.setEnabled(true);
jTextField1.setEnabled(true);
jButton1.setEnabled(true);
jLabel2.setEnabled(false);
jTextField2.setEnabled(false);
jButton2.setEnabled(false);
jLabel3.setEnabled(false);
jTextField3.setEnabled(false);
jButton3.setEnabled(false);
12
jLabel4.setEnabled(true);
jTextField4.setEnabled(true);
jLabel2.setEnabled(false);
jTextField2.setEnabled(false);
jButton2.setEnabled(false);
jLabel1.setEnabled(false);
jTextField1.setEnabled(false);
jButton1.setEnabled(false);
13
16. Vote Eligibility
Objective: To check the eligibility to vote.
Design:
Coding:
On the click of jButton1:
If (Integer.parseInt(jTextField1.getText())>=18)
JOptionPane.showMessageDialog(null, You are eligible to
vote);
else
JOptionPane.showMessageDialog(null, You are not eligible
to vote);
Coding:
On the click of jButton1:
14
if (Integer.parseInt(jTextfield1.getText())>=75)
{
jTextArea1.setText(Congrats! You can take the
scholarship!);
}
else
{
jTextArea1.setText(Sorry, you are not eligible but better
luck next time);
}
Coding:
On the click of jButton1:
int date,day;
date=Integer.parseInt(jTextField1.getText());
if (date<=31)
{
if (date % 7 == 1)
{
JOptionPane.showMessageDialog(null, "It's a friday!");
}
else if (date % 7 == 2)
{
JOptionPane.showMessageDialog(null, "It's a saturday!");
}
else if (date % 7 == 3)
{
JOptionPane.showMessageDialog(null, "It's a Sunday!");
}
15
else if (date % 7 == 4)
{
JOptionPane.showMessageDialog(null, "It's a Monday!");
}
else if (date % 7 == 5)
{
JOptionPane.showMessageDialog(null, "It's a tuesday!");
}
else if (date % 7 == 6)
{
JOptionPane.showMessageDialog(null, "It's a
wednesday!");
}
else if (date % 7 == 0)
{
JOptionPane.showMessageDialog(null, "It's a thursday!");
}
}
else
{
JOptionPane.showMessageDialog(null, "My Logic Says
That A Month Can Have A Maximum Of 31 Days. Please Try
Again!");
}
16
On the click of jButton1:
double amount=0;
if (jCheckBox1.isSelected())
{
jTextField1.setText("2500");
amount=amount+2500;
}
if (jCheckBox2.isSelected())
{
jTextField2.setText("1500");
amount=amount+1500;
}
if (jCheckBox3.isSelected())
{
jTextField3.setText("2000");
amount=amount+2000;
}
if (jCheckBox4.isSelected())
{
jTextField4.setText("3000");
amount=amount+3000;
}
if (jCheckBox5.isSelected())
{
jTextField5.setText("3500");
amount=amount+3500;
}
jTextField6.setText(Double.toString(amount));
17
On the click of jButton2:
System.exit(0);
Coding:
On the click of jButton1:
int total=0;
if (jList1.isSelectedIndex(0)==true)
{
total=total+150;
JOptionPane.showMessageDialog(this,"Pasta - Rs.150");
}
if (jList1.isSelectedIndex(1)==true)
{
total=total+250;
JOptionPane.showMessageDialog(this,"Pizza - Rs.250");
}
if (jList1.isSelectedIndex(2)==true)
{
total=total+100;
JOptionPane.showMessageDialog(this,"Burger -
Rs.100");
}
if (jList1.isSelectedIndex(3)==true)
{
total=total+70;
18
JOptionPane.showMessageDialog(this,"French Fries -
Rs.70");
}
jTextField1.setText(Integer.toString(total));
Coding:
On the click of jButton1:
if (jComboBox1.getSelectedIndex()==0)
JOptionPane.showMessageDialog(null, "It is known as
silicon valley of India");
else if (jComboBox1.getSelectedIndex()==1)
JOptionPane.showMessageDialog(null, "It is the
capital city of India");
else if (jComboBox1.getSelectedIndex()==2)
JOptionPane.showMessageDialog(null, "It is known for
broad industrial base");
else if (jComboBox1.getSelectedIndex()==3)
JOptionPane.showMessageDialog(null, "It is known for
literacy, artistic and revolutionary heritage");
else if (jComboBox1.getSelectedIndex()==4)
JOptionPane.showMessageDialog(null, "It is known for
hub of bollywood");
19
Objective: to make a discount calculator using switch
statement.
Design:
Coding:
On the click of jButton1:
double FinalAmount=0;
double
BillAmount=Double.parseDouble(jTextField1.getText());
switch(jComboBox1.getSelectedIndex())
{
case 0: FinalAmount=BillAmount;
break;
case 1: FinalAmount=0.90*BillAmount;
break;
case 2: FinalAmount=0.80*BillAmount;
break;
case 3: FinalAmount=0.70*BillAmount;
break;
default:FinalAmount=BillAmount;
}
jTextField2.setText(Double.toString(FinalAmount));
20
Coding:
On the click of jButton1:
long LastNumber=Long.parseLong(jTextField1.getText());
for (long I=1;I<=LastNumber;I++)
{
jTextArea1.setText(jTextArea1.getText()+"
"+Long.toString(I));
}
21
Coding:
On the click of jButton1:
int LN = Integer.parseInt(jTextField1.getText());
if (jRadioButton1.isSelected())
{
for (int i=2;i<=LN;i+=2)
jTextArea1.setText(jTextArea1.getText()+"
"+Integer.toString(i));
}
else if (jRadioButton2.isSelected())
{
for (int i=1;i<=LN;i+=2)
jTextArea1.setText(jTextArea1.getText()+"
"+Integer.toString(i));
}
else
{
JOptionPane.showMessageDialog(this,"Hey Man, What's
Your Problem?! Atleast Select One Of The Option!");
}
22
25. Members Counter
Objective: to make an application which counts the name
inputs by user.
Design:
Coding:
On the click of jButton1:
int More=0,CountName=0;
String Name;
do
{
Name=JOptionPane.showInputDialog("Enter member
name:");
Name=Name+"\n"+jTextArea1.getText();
jTextArea1.setText(Name);
CountName=CountName+1;
jTextField1.setText(Integer.toString(CountName));
More=JOptionPane.showConfirmDialog(this, "More
Names","Confirm",JOptionPane.YES_NO_OPTION);
}
while (More==0);
23
24