CJCoding With Joseph
15free / daySign inCreate account

Door Open Or Closed

A door starts closed. 1) Open prints Door opened. and remembers the door is open, or Already open. when it is; 2) Close prints Door closed. or Already closed. the same way; 3) Quit prints Goodbye! and leaves the loop; anything else prints Unknown choice - try again.. The close branch is written; write the open branch so the is_open flag is only changed when the action makes sense. Input: one choice per line, ending with 3. Prompts are part of the output, so each message follows Choice: .

Expected Output:

1) Open
2) Close
3) Quit
Choice: Door opened.
1) Open
2) Close
3) Quit
Choice: Already open.
1) Open
2) Close
3) Quit
Choice: Door closed.
1) Open
2) Close
3) Quit
Choice: Goodbye!

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Menus & Validation
📥 Auto-Input:
1\n1\n2\n3\n
This input is automatically fed to your program's stdin
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.