Question: 1 0 . 8 * zyLab: Division Exceptions In this lab, we want a program that can take in two integers and determine if the
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 trycatch 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 cases each corresponding to a different type of exception we are concerned with.
If the user inputs values other than integers, you should output:
Numerator and denominator must be integers. Please try again.
If the user inputs a value of for the denominator, you should output:
Did you try to divide by Please try again.
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:
Enter denominator:
waffleswaffleswaffles
Numerator and denominator must be integers. Please try again.
Enter numerator:
Enter denominator:
Did you try to divide by Please try again.
Enter numerator:
Enter denominator:
is not evenly divisible by
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
