InterviewSolution
| 1. |
Mr. Radhey Shyam Bansal the owner of the Kiddi Land Enterprise has asked his programmer Ekta to develop the following GUI in Netbeans.Mr. Bansal accepts payment through three types of credit cards. The discount is given according to the following scheme:Type of CardDiscountPlatinum20% of amountGold15% of amountSilver10% of amountIf the bill amount is more than Rs. 25,000/- then the customer gets an additional offer of 5%. Write Java code for the following:(i) To assign Additional Discount as 0 (jTextField4) and Net amount as 0 (jTextField5). Also set them as un-editable. [When "Calculate Discount" (jButton1) is clicked](ii) To calculate discount as per the given criteria and display the same in jTextField3 To assign Additional Discount (jTextField4) as 5% of amount (jTextField2) as per the above condition. (iii) To enable "Calculate Net Amount" (jButton2) button [When "Calculate Net Amount" (jButton2) button is clicked] To calculate net amount as [TotalCost (jText- Field2)- Discount (jTextField3) -Additional Discount (jTextFielda)]To display the net amount in jTextField5. |
|
Answer» (i) jTextField4.setText("0"); jTextField5.setText("0"); jTextField4.setEditable(false); jTextField5.setEditable(false); (ii) double discount = 0.0 ; double billAmount = Double. parseDouble(jTextField2.getText()); if(jRadioButton1.isSelected()) discount = 0.20; if(jRadioButton2.isSelected()) discount = 0.15; if(jRadioButton3.isSelected()) discount = 0.10; jTertField3.setText(billAmount * discount + " ") if (billAmount > 25000) jTextField4.setText(billAmount * 0.05+ " "); jButton2.setEnabled(true); (iii) doube netAmount = Double. parseDouble(jTextField2.getText()) - Double. parseDouble(jTextField3.getText()) -Double. parseDouble(jTextField4.getText()); jTextField5.setText(netAmount + " "); |
|