โ 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): Enter a number: 5 Enter a number: -2 Enter a number: 1 Enter a number: 0 Game Over!
Expected Output:
Enter a number: 5 Enter a number: -2 Enter a number: 1 Enter a number: 0 Game Over!
Topics:
LoopsUser Input
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.