← Back to Menus & Validation
Question 441
Light Switch Menu
Light Switch Menu
A menu switches a light: 1) Turn on prints Light is on., 2) Turn off prints Light is off., 3) Quit prints Goodbye! and leaves the loop, and anything else prints Unknown choice - try again.. The first two branches and the catch-all are written; add the quit branch. The choice is read with the prompt Choice: and stripped. Input: one choice per line, the last one 3. The prompt is part of the output, so each message follows Choice: on the same line.
Expected Output:
1) Turn on 2) Turn off 3) Quit Choice: Light is on. 1) Turn on 2) Turn off 3) Quit Choice: Goodbye!
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Menus & Validation
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.