CJCoding With Joseph
15free / daySign inCreate account

Counter Menu

A counter starts at 0. Show a four-line menu, 1) Add 1, 2) Subtract 1, 3) Show and 4) Quit, and read the choice with the prompt Choice: , stripped. Choice 1 adds one and prints Count is now <n>., choice 2 subtracts one and prints the same sentence, choice 3 prints Count: <n>, choice 4 prints Goodbye! and leaves the loop, and anything else prints Unknown choice - try again.. Input: one choice per line, ending with 4. The prompt is part of the output, so each message follows Choice: on the same line.

Expected Output:

1) Add 1
2) Subtract 1
3) Show
4) Quit
Choice: Count is now 1.
1) Add 1
2) Subtract 1
3) Show
4) Quit
Choice: Count is now 2.
1) Add 1
2) Subtract 1
3) Show
4) Quit
Choice: Count is now 1.
1) Add 1
2) Subtract 1
3) Show
4) Quit
Choice: Count: 1
1) Add 1
2) Subtract 1
3) Show
4) Quit
Choice: Goodbye!

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

Hints4 available
Topics:
Menus & Validation
📥 Auto-Input:
1\n1\n2\n3\n4\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.