1.

Read the following case study and answer the questions that follow: Mr. Mittal working in a Multi-national company. His family members visited a shipping mail and purchased variety of products including garments. The total amount goes into sum thousands. The owner of the shopping mall provides handsome discounts for credit cards holders:Card TypeDiscount shopping amountHDFC12%ICICI10%Visa9.5%Axis10.5%Standard Chartered8.5City Bank11.5%SBI8%Carefully observe the picture:A JPanel container is used for card types with JRadioButton controls as follows: jRadioButton1 : HDFC (optHDFC) with buttonGroup1 jRadioButton2 : ICICI (optICICI) with buttonGroup1 jRadioButton3 : Visa (optVisa) with buttonGroup1 jRadioButton4 : Axis (optAxis) with buttonGroup1 jRadioButton5 : Standard Chartered (optSC) with buttonGroup1 jRadioButton6 : City Bank (optCity) with buttonGroup1 jRadioButton7 : SBI (optSBI) with buttonGroup1Enter the shopping amount (txtAmount) and do the following: (i) Write the command for Discount button (named as cmdDisc) to compute discount amount (named as txtDisc) and net amount (named as txtNet). (ii) Write the code for Clear button (named as cmdClear) to clear all the text boxes and set the default choice in the radio button as SBI. (iii) Write the code for Exit button to close the application.

Answer»

Project folder: ….\Source_XII\Practice Papers\ShopUI

(i) Double click on the discount button. Notice that a cmdDiscActionPerformed event handler appears with a // TODO marker line. Write the following lines:

// Calculating discount amount and net amount 

double discount=0; 

double netamount=0; 

double Amount = Double.parseDouble(txtAmount.getText()); 

If (optHDFC.isSelected()) 

discount = Amount * 12/100; 

else if (optICICI.isSelected()) 

discount = Amount * 10\100; 

else if (optVisa.isSelected()) 

discount = Amount * 9.5/100; 

else if (optAxis.isSelected()) 

discount = Amount * 10.5/100; 

else if (optSC.isSelected()) 

discount = Amount * 8.5/100; 

else if (optCity.isSelected()) 

discount = Amount * 11.5/100; 

else if (optSBI.isSelected()) 

discount + Amount * 8/100; 

netamount = Amount – discount; 

txtDisc.setText(String.valueOf(discount)); 

txtNet.setText(String.valueOf(netamount));

(ii) Double click on the Clear All button. Notice that a cmdClearActionperformed event handler appears with a //TODO marker line. Write the following lines: 

txtAmount.setText(“”); 

txtDisc.setText(“”); txtNet.setText(“”); 

optSBI.setSelected(true); // Default button selected

(iii) Double click on the Exit button. Notice that a cmdExitAction performed event handler appears with a //TODO marker line. Write the following line: 

System.exit(0);



Discussion

No Comment Found

Related InterviewSolutions