CJCoding With Joseph

Multiple Catch Blocks

Read two integers and print their quotient. Use two separate catch blocks: a FormatException prints Not a valid number, and a DivideByZeroException prints Cannot divide by zero. The order matters: the more specific type is matched first. Use top-level statements.

Input 10 then 2 prints: 5
Input 10 then 0 prints: Cannot divide by zero
Input x then 2 prints: Not a valid number

Expected Output:

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