Ch3 XII Solutions
Ch3 XII Solutions
3. Design a GUI application to accept the cost price and selling price form the user in two
text fields then calculate the profit or loss incurred.
A) Design;
Output;
4. Design a GUI application to accept a character in a text field and print in a label if that
character is a vowel: a, e, i, o, or u. The application should be case sensitive.
A) Design view;
Coding for jButton1 (“Check if it is a vowel”);
String in;
in=jTextField1.getText();
switch (in){
case "a":
case "e":
case "i":
case "o":
case "u":
case "A":
case "E":
case "I":
case "O":
case "U":
jLabel4.setText(in+" is a vowel.");
break;
default:
jLabel4.setText(in+" is not a vowel. It is a consonent.");}
}
Output;
5. Design a GUI application that repeatedly accepts numbers in a JOptionPane and once
the typed number is 0 the maximum and minimum of all numbers typed are displayed.
A)
Output;
7. Design a GUI application in java to convert kilograms into grams, litres into milliliters,
rupees into paisa using combobox and text fields.
A)
Coding for jButton1 (‘Convert now’);
double in,r;
in=Double.parseDouble(jTextField1.getText());
r=0;
if (jComboBox1.getSelectedItem().equals("Kilograms to grams")){
r=in*1000;}
if (jComboBox1.getSelectedItem().equals("Litres to mililitres")){
r=in*1000;}
if (jComboBox1.getSelectedItem().equals("Rupees to paisa (INR)")){
r=in*100;}
jTextField2.setText(Double.toString(+r));
Output;
9. A networking company decided to computerize its employee salary . Develop an
application to store employee's personal data which will be saved in the back end. The
front end should accept Name, Father's Name, Mother's Name, Address, Gender, Basic
Salary, Medical and Conveyance. Calculate gross and net salary.
A)