CJCoding With Joseph
15free / daySign inCreate account

Two Catch Blocks

Read two integers and print a / b. Handle two different failures with two catch blocks: a FormatException (bad number) prints Invalid number, and a DivideByZeroException prints Cannot divide by zero. Use top-level statements with try/catch.

Input 20 then 4 prints: 5
Input 20 then 0 prints: Cannot divide by zero
Input x then 4 prints: Invalid number

Expected Output:

5

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

Hints4 available
Topics:
Exceptions
📥 Auto-Input:
20\n4\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 (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.