Académique Documents
Professionnel Documents
Culture Documents
1
2
EXPERIMENT – 1
Objective: Understanding and use of variables of float and other datatypes.
Task: Develop a simple calculator app as per the screenshot, to implement +,-,
x, / operations. The text boxes get cleared when c button is clicked.
Design View: -
a = Integer.parseInt(jTextField1.getText());
b = Integer.parseInt(jTextField2.getText());
c = a+b;
jTextField3.setText(c+"");
3
a = Integer.parseInt(jTextField1.getText());
b = Integer.parseInt(jTextField2.getText());
c = a-b;
jTextField3.setText(c+"");
int a,b,c;
a = Integer.parseInt(jTextField1.getText());
b = Integer.parseInt(jTextField2.getText());
c = a*b;
jTextField3.setText(c+"");
int a,b, c;
a = Integer.parseInt(jTextField1.getText());
b = Integer.parseInt(jTextField2.getText());
c = a/b;
jTextField3.setText(c+"");
Code for ‘C’ button:
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
4
Output Window :
5
Experiment – 2
Objective: Understanding the real-life application requirement and
developing a solution.
principle = Double.parseDouble(jTextField1.getText());
rate = Double.parseDouble(jTextField2.getText());
time = Double.parseDouble(jTextField3.getText());
while(i<=time)
{
a = a*(1+rate/100);
6
i++;
}
amount = principle*a;
jTextField4.setText(amount+"");
interest = amount-principle;
jTextField5.setText(interest+"");
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
Code for ‘CLOSE’ button:
System.exit(0);
Output window:
7
Experiment – 3
Objective: Understanding and use of nested conditions in real-life
applications.
distance = Integer.parseInt(jTextField4.getText());
weight = Integer.parseInt(jTextField3.getText());
if(distance<500)
{
if(weight<100)
8
charge = 5;
else
charge = 8;
else
if(weight<10)
charge = 7;
else if(weight<100&&weight>10)
charge = 6;
else
charge = 5;
}
amount = charge*distance;
jTextField5.setText(amount+"");
Code for ‘EXIT’ button:
System.exit(0);
9
Output Window:
10
Experiment – 4
Objective: Understanding and use of nested loops and use of Text Area
control.
Task: Develop a JAVA application to print a pattern for given character and
steps as per given screenshot.
Design View:
String a = jTextField1.getText();
for(int i = 1; i<=x; i++)
11
jTextArea1.append("\n");
}
Code for ‘EXIT’ button:
System.exit(0);
Output Window :
12
Experiment – 5
Objective: Understanding the use of loops and mathematical operation.
Design View :
a+=(x%i);
}
jTextField2.setText(a+"");
System.exit(0);
13
Output Window :
14
Experiment – 6
Objective: Understanding and developing a logic to solve a problem. Use of
nested loops and breaking it pre-maturely.
num = Integer.parseInt(jTextField2.getText());
for(; i<=num; i++)
15
if(i%y==0)
{
flag = 0;
break;
else
flag = 1;
if(flag==1)
jTextArea1.append(i+", ");
Output Window :
16
Experiment – 7
Objective: Use of slider or scroll bar control to get user input and using it for
some calculation.
double temp;
i = jSlider1.getValue();
temp = (i*1.8)+32;
jTextField1.setText(temp+"");
}
Output Window :
17
18
Experiment – 8
Objective: Displaying images on a Label and Text Area control.
Task: Develop an e-learning application with image and text information as per
the given screenshot.
Design View :
19
Code for ‘MOUSE’ button:
jLabel3.setIcon(new ImageIcon("D:\\Documents\\ IP
PROJECT\\mouse.jpg"));
Code for ‘MONITOR’ button:
jTextArea1.setText("A computer monitor is an output device that
displays information in pictorial form. The display device in modern
monitors is typically a thin film transistor liquid crystal display (TFT-
LCD) with LED backlighting having replaced cold-cathode fluorescent
lamp (CCFL) backlighting.");
20
Output Window :
21
Experiment – 9
Objective: Demonstration of use of List/Combo box dynamically through
code.
Task: Develop an application as per the given screenshot to add, remove the
given members of the list and display selected item in a text field using
List/Combo Box control.
Design View :
22
Code for ‘ADD’ button:
dl.addElement(item);
jTextField1.setText("");
dl.removeElement(remove);
jTextField3.setText("");
System.exit(0);
23
Output window:
24
Experiment – 10
Objective: Understanding and using the radio button in real life application.
Task: Develop a billing application for Happy Shoppers & Retail chain
involved in sales of readymade garments. The Happy Shopping offers
discount to its members holding platinum, gold and silver cards. The
10% discount is given to platinum card, 8% to gold card and 5% to silver
card holders on sales amount.
Design View :
double disc;
if(jRadioButton1.isSelected())
disc = 0.1;
else if(jRadioButton2.isSelected())
disc = 0.08;
else
disc = 0.05;
25
int price, qty;
price = Integer.parseInt(jTextField2.getText());
qty = Integer.parseInt(jTextField3.getText());
totalamount = price*qty;
discount = disc*totalamount;
netamount = totalamount-discount;
jTextField4.setText(totalamount+"");
jTextField5.setText(discount+"");
jTextField6.setText(netamount+"");
Output Window :
26