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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!