InterviewSolution
| 1. |
Seema is a junior Programmer at 'Avon Shoe Factory'. She has created the following GUI in Netbeans.(i) Items namely Shoes, Sandals and Slippers are manufactured by the factory. (ii) A buyer can buy more than one item at a time. (iii) Each pair of shoes costs Rs1,500.00, each pair of sandals costs Rs1,000.00 and each pair of slippers cost Rs 500.00. (iv) The item bought will be selected by the user and the Quantity (number of pairs) bought will be entered by the user. (v) Amount to be paid for that item will be displayed in front of the item. For example if 'Shoe' is selected and quantity entered is 20, then Amount should be displayed as 30000. Help Seema to write code for the following:(i) When 'Calculate' button is clicked, the amount should be displayed in front of each item (in the appropriate textfield) and Total amount (sum total of all the amounts) should be displayed in the appropriate textfield. (ii) When Clear button is clicked, all the Textfields and Checkboxes should be cleared. (iii) When Stop button is clicked, the application should close. |
|
Answer» (i) float qty1 = 0, qty2 = 0, qty3 = 0,amt1 = 0,amt2 = 0 ,amt3 = 0,total; if (jCheckBox1.isSelected()) qty1 = Float.parseFloat(jTextField1.getText()); if (jCheckBox2.isSelected()) qty2 = Float.parseFloat(jTextField2.getText()); if ( CheckBox3.isSelected()) qty3 = Float.parseFloat(jTextField3.getText()); amt1 = qty1 * 1500; amt = qty2 * 1000; amt = qty3 * 500; total = amt1 + amt2 + amt3; jTextField4.setText(" " + amt1); jTextField5.setText(" " + amt2); jTextField6.setText(" " + amt3); jTextField7.setText(" " + total); (ii) jTextField1.setText(" "); jTextField2.setText(" ") ; jTextField3.setText(" ") ; jCheckBox1.setSelected(false); (iii) System.exit(0); |
|