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
+1 vote
6.9k views
in Information Technology by (71.3k points)

Mr. Suman, a programmer in New Era Programming World has designed a registration page for a hobby club as shown below:

Fee for different hobbies are as follows:

Hobby Fee
Dancing 1000
Drawing 1500
Music 2000
Singing 2500

Help him in writing the code to do the following:

(i) As per the hobby chosen in the hobby combo box, fee should be displayed in the respective text field named t1 as per the criteria given above after clicking on “Check Fee” button.

(ii) If a candidate belongs to “Jr. Category” then a discount of 10% should be given in displayed in the text field.

(iii) After clicking on the “Net Fee” button, Net Fee should be calculated and displayed in the respective text field as per the given formula:

Net Fee = Fee – Discount

(iv) Write suitable java code to close the application.

(v) Write java statement to add a new hobby “Reading” in the combo box at run time.

1 Answer

+2 votes
by (76.5k points)
selected by
 
Best answer

(i) int x=c1.getSelectedIndex();

int fee=0;

if(x==0)

fee=1000;

else if(x==1)

fee=1500;

else if(x==2)

fee=2000;

else if(x==3)

fee=2500;

t2.setText(""+fee);

(ii) double disc=0;

int fee=Integer.parseInt(t2.getText());

if(r2.isSelected())

disc=fee*10/100;

t3.setText(""+disc);

(iii) double disc=Double.parseDouble(t3.getText());

int fee=Integer.parseInt(t2.getText());

double net=fee-disc;

t4.setText(""+net);

(iv) System.exit(0);

(v) c1.addItem("Reading");

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

...