1.

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:HobbyFeeDancing1000Drawing1500Music2000Singing2500Help 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.

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");



Discussion

No Comment Found

Related InterviewSolutions