InterviewSolution
Saved Bookmarks
| 1. |
Deepti works as a programmer in a travel company. She has developed the following code to display travel detail according to user’s choice. Help her in rewriting the same code using SWITCH CASE :if (choice==1 ) jTextFieldl.setText ("New Delhi to Goa") ;elseif (choice = 2) jTextFieldl.setText ("New Delhi to Paris") ;elseif (choice = 3) jTextFieldl.setText ("New Delhi to Bangkok") ;elsejTextFieldl.setText ("PI. choose valid option") ; |
|
Answer» switch (choice) { Case 1 : JTextFieldl. setText ("New Delhi to Goa") ; break ; Case 2 : jTextFieldl.setText ("New Delhi to Paris") ; break ; Case 3 : jTextFieldl.setText ("New Delhi to Bangkok") ; break ; default: jTextFieldl.setText ("P1. choose valid option") ; } |
|