Está en la página 1de 24

Informatics

Practices
Working with NetBeans

Submitted to: Rajeev Kumar Sir

Submitted by: Ishaan Pathak; Class XI-S; Roll no. 26

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");

On the click of jButton2:


JOptionPane.showMessageDialog(null,"Good Evening");

On the click of jButton3:


System.exit(0);

4. Text Field Wish


Objective: Display message in a Text Field on the click of a
button
Design:

Coding:
On the click of jButton1:
jTextField1.setText("Good Morning");

On the click of jButton2:


jTextField1.setText("Good Evening");

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());

On the click of jButton2:


jTextField2.setText(Good Evening + jTextField.getText());

On the click of jButton3:


System.out(0);

6. Name with Title


Objective: To display a name with title.

4
Design:

Coding:
On the click of jRadioButton1:
jTextField2.setText("Mr. " + jTextField1.getText());

On the click of jRadioButton2:


jTextField2.setText("Mr. " + jTextField1.getText());

7. Text Area Application


Objective: To show a message in text box.
Design:

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.);

On the click of jButton2:


jTextArea1.setText(jTextfield1.getText() + and +
jTextField2.getText() + are good colleagues. \n + and is
always ready to help you.);

On the click of jButton3:


System.exit(0);

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);

On the click of jButton2:


System.exit(0);

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()));

On the click of jButton2:


jTextField2.setText(Integer.toString(24*Integer.parseInt(jTe
xField1.getText()));

On the click of jButton3:


System.exit(0);

10. Simple Calculation


Objective: To make an amount calculator using numbers with
decimals.
Design:

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);

11. Fruit Calculator


Objective: To add values accept in three text fields and display
result in fourth text field.
Design:

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())));

On the click of jButton2:


System.exit(0);

12. Magic Text


Objective: To develop a simple application to learn the use and
handling of char data type.
Design:

8
Coding:
On the click of jButton1:
Char star;
star = *;
jTextField2.setText(star+jTextfield1.getText()+star);

On the click of jButton2:


Char hash;
hash = #;
jTextField2.setText(hash+jTextfield1.getText()+hash);

On the click of jButton3:


Char percent;
star = %;
jTextField2.setText(percent+jTextfield1.getText()+percent);

On the click of jButton4:


Char quotes;
star = ;
jTextField2.setText(quote+jTextfield1.getText()+quote);

On the click of jButton5:


System.exit(0);

13. Basic Calculator


Objective: To make a basic calculator for two numbers
Design:

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));

On the click of jButton2:


int a,b,d;
double f;
a=Integer.parseInt(jTextField1.getText());
b=Integer.parseInt(jTextField2.getText());
d=b-a;
jTextField3.setText(Integer.toString(d));

On the click of jButton3:


int a,b,e;
double f;
a=Integer.parseInt(jTextField1.getText());
b=Integer.parseInt(jTextField2.getText());
e=a*b;
jTextField3.setText(Integer.toString(e));

On the click of jButton4:


int a,b;
double f;
a=Integer.parseInt(jTextField1.getText());
b=Integer.parseInt(jTextField2.getText());
f=a/b;
jTextField3.setText(Double.toString(f));

On the click of jbutton5:


jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
On the click of jButton6:
System.exit(0);

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));

On the click of jButton2:


Sytem.exit(0);

15. Area Calculator


Objective: To make an area calculator of a circle, rectangle, or a
square.
Design:

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);

On the click of jRadioButton2:


jLabel1.setEnabled(false);
jTextField1.setEnabled(false);
jButton1.setEnabled(false);
jLabel3.setEnabled(false);
jTextField3.setEnabled(false);
jButton3.setEnabled(false);
jLabel2.setEnabled(true);
jTextField2.setEnabled(true);
jButton2.setEnabled(true);

On the click of jRadioButton3:


jLabel3.setEnabled(true);
jTextField3.setEnabled(true);
jButton3.setEnabled(true);

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);

On the click of jButton1:


jTextField5.setEditable(false);
jLabel5.setEnabled(true);
jTextField5.setEnabled(true);
double r,a;
r=Double.parseDouble(jTextField1.getText());
a=3.14*r*r;
jTextField5.setText(Double.toString(a));

On the click of jButton2:


jTextField5.setEditable(false);
jLabel5.setEnabled(true);
jTextField5.setEnabled(true);
int s,a;
s=Integer.parseInt(jTextField2.getText());
a=s*s;
jTextField5.setText(Integer.toString(a));

On the click of jButton3:


jTextField5.setEditable(false);
jLabel5.setEnabled(true);
jTextField5.setEnabled(true);
jLabel4.setEnabled(true);
jTextField4.setEnabled(true);
int l,a,b;
l=Integer.parseInt(jTextField3.getText());
b=Integer.parseInt(jTextField4.getText());
a=l*b;
jTextField5.setText(Integer.toString(a));

On the click of jButton4:


System.exit(0);

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);

On the click of jButton2:


System.exit(0);

17. Scholarship eligigbility


Objective: To check the eligibility to avail scholarship.
Design:

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);
}

On the click of jButton2:


System.exit(0);

18. Week Day Finder for August 2016


Objective: To find the day of the week.
Design:

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!");
}

19. Sports Charges


Objective: To make an application to learn manipulation of
check boxes.
Design:

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);

20. Restaurant Order


Objective: To make a restaurant order application.
Design:

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));

21. City highlights


Objective: to design the application city highlights.
Design:

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");

22. Discount Calculator V2.0

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));

On the click of jButton2:


System.exit(0);

23. Natural Number Printer


Objective: to make an application that prints natural numbers
till the number input.
Design:

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));
}

On the click of jButton2:


System.exit(0);

24. Even Odd Number Printer


Objective: to make an application to print even or odd numbers.
Design:

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!");
}

On the click of jButton2:


jTextArea1.setText("");
jTextField1.setText("");
On the click of jButton3:
System.exit(0);

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);

On the click of jButton2:


System.exit(0);

23
24

También podría gustarte