← Back to Loops
Question 53
Break on Zero (while input)
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
Sign in to use hintsTopics:
LoopsUser Input
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.