CJCoding With Joseph
15free / daySign inCreate account

Break on Zero (while input)

Keep asking for numbers in a while loop and break when the user enters 0. For each input, print a prompt and echo the number just read, then when 0 is entered, break and print 'Game Over!'.

Output format per input:
Enter a number: [value]

Example (inputs: 5, -2, 1, 0): see Expected Output.

Expected Output:

Enter a number: 5
Enter a number: -2
Enter a number: 1
Enter a number: 0
Game Over!

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

Hints4 available
Topics:
LoopsUser Input
📥 Auto-Input:
5\n-2\n1\n0\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 · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.