Question
Exercise 3: Handle exceptions (20 points) Write a java program with customized exception handling. In your main method, you will take two integers x and
Exercise 3: Handle exceptions (20 points)
Write a java program with customized exception handling. In your main method, you will take two integers x and y as input, you have to compute y/x as the output. If x and y are not 32-bit signed integers or if x is zero, exception will occur and you have to report it. Read sample Input/Output to know what to report in case of exceptions.
Sample Input 1:
10
3
Sample Output 1:
3
--------------------------------------------------
Sample Input 2:
10
Hello
Sample Output 2:
java.util.InputMismatchException
--------------------------------------------------
Sample Input 3:
10
0
Sample Output 3:
java.lang.ArithmeticException: / by zero
--------------------------------------------------
Sample Input 4:
23.323
0
Sample Output 4:
java.util.InputMismatchException
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started