Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
91 views
in Computer by (41.5k points)
closed by

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 Type Discount shopping amount
HDFC 12%
ICICI 10%
Visa 9.5%
Axis 10.5%
Standard Chartered 8.5
City Bank 11.5%
SBI 8%

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 buttonGroup1

Enter 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.

1 Answer

+1 vote
by (47.1k points)
selected by
 
Best 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);

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...