CJCoding With Joseph

Invalid Operation Exception

Read a count. If it is 0, throw new InvalidOperationException("stack is empty"); otherwise print Popped from <count> items. Catch the exception and print Error: <message>. Use top-level statements with try/catch.

Input 3 prints: Popped from 3 items
Input 0 prints: Error: stack is empty

Expected Output:

Popped from 3 items
Topics:
Exceptions
๐Ÿ“ฅ Auto-Input:
3\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.