Question: 1 0 . 8 * zyLab: Division Exceptions In this lab, we want a program that can take in two integers and determine if the

10.8*zyLab: Division Exceptions
In this lab, we want a program that can take in two integers and determine if the first integer is evenly divisible by the second integer. Luckily, I have already wrote this method (isDivisible) for you! Unfortunately, I did a careless job and didn't consider any of the possible unchecked exceptions that could occur during runtime. Since you still want to use my method instead of writing your own from scratch, you will have to utilize try/catch blocks to handle the potential exceptions my method may throw.
We want the program to continuously call isDivisible until isDivisible is able to run once without any exceptions being thrown (or we run out of input). There are 3 cases (each corresponding to a different type of exception) we are concerned with.
1) If the user inputs values other than integers, you should output:
Numerator and denominator must be integers. Please try again.
2) If the user inputs a value of 0 for the denominator, you should output:
Did you try to divide by 0? Please try again.
3) If an exception is thrown because there is no more user input, then you can output the following and end the program:
No more input. Exiting program.
You will accomplish this by only editing the main method (do not edit isDivisible).
Below is an example of correct program output:
Enter numerator:
howdy
Numerator and denominator must be integers. Please try again.
Enter numerator:
4
Enter denominator:
waffleswaffleswaffles
Numerator and denominator must be integers. Please try again.
Enter numerator:
4
Enter denominator:
0
Did you try to divide by 0? Please try again.
Enter numerator:
4
Enter denominator:
3
4 is not evenly divisible by 3

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!