1.

Ms. Sharma works as a programmer in “ABC Car Rental Company” where she has designed a software to compute charges to be paid by the client. A screenshot of the same is shown below:A client can take any car out of Deluxe/ SemiDeluxe/ Ordinary for rent. A client can also opt for services of a guide. Charges vary depending on the type of car opted. Charges of services of Guide are extra. Help Ms. Sharma in writing the code to do the following:After selecting appropriate Radio Button and checkbox (if required), when ‘CALCULATE’ button is clicked, Amount, Guide Charges and Total Amount should be calculated and displayed in the respective text fieldsCategory of CarAmount (In Rs.)Deluxe Car1000 per daySemi deluxe car800 per dayOrdinary car700 per dayAmount is obtained by multiplying per day charges of Car with number of days for which the car is taken. If ‘Guide Required’ checkbox is selected, Guide charges per day are Rs.500.00. Guide Charges is calculated as :Car required for No. of days * 500; Total Amount = Amount + Guide Charges

Answer»

// Calculation of Amount 

if (jRadioButton1.isSelected()) 

jTextField3.setText("" + 1000* 

Integer.parseInt(jTextField2.getText())); 

if (jRadioButton2.isSelected() 

jTextField3.setText("" + 800* 

Integer.parseInt(jTextField2.getText())); 

if (jRadioButton3.isSelected()) 

jTextField3.setText("" + 700* 

Integer.parseInt(jTextField2.getText())); 

//Calculation of Guide Charges 

if(jCheckBox1.isSelected()) 

jTextField4.setText("" + 500* 

Integer.parseInt(jTextField2.getText())); 

//Total Amount 

jTextField5.setText("" + 

(Integer.parseInt(jTextField3.getText())+ 

Integer.parseInt(jTextField4.getText())));

(ii) When ‘CLEAR’ button is clicked, all the textfields and checkboxes should be cleared. 

jTextField1.setText(""); 

jTextField2.setText(""); 

jTextField3.setText(""); 

jTextField4.setText(""); 

jTextField5.setText(""); 

jTextField6.setText(“”); 

jCheckBox1.setSelected(false); 

(iii) When ‘CLOSE’ button is clicked, the application should close. System.exit(0);



Discussion

No Comment Found

Related InterviewSolutions