Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions

Question

What would the profession expect of Principal Smith?

Answered: 1 week ago

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago