CJCoding With Joseph

Nested Try/Catch

Read an integer n. Inside an inner try, print 10 / n; its catch handles DivideByZeroException by printing Inner caught division error. The outer try wraps the parsing and catches FormatException by printing Outer caught format error. Use top-level statements with nested try/catch.

Input 2 prints: 5
Input 0 prints: Inner caught division error
Input x prints: Outer caught format error

Expected Output:

5
Topics:
Exceptions
๐Ÿ“ฅ Auto-Input:
2\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.