Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4 (30 points) 1. Create a user defined exception class called NonIntResultException which is generated when the result of dividing two integers values produces
Question 4 (30 points) 1. Create a user defined exception class called NonIntResultException which is generated when the result of dividing two integers values produces a result with a fractional component (ie the result is not an integer) NonIntResultException contains: 1. A constructor with parameters that represent the two integer values 2. Generates an appropriate message, for example if the two integers are 7 and 2. The resulting Exception message would be Result of 7 divided by 2 is not an integer 2. Create the IntegerArrayMath classe's integerDivision method(see examples and code snippet below) the method: 1. Loops thru numer instance field array and attempts to divide each value of numer array by the corresponding 2. If the result of the division is an integer then print out a print out a message indicating the results of the divisiorn 3. If the result of the division is not an integer then throw and handle a NonIntResultException and continue 4. The method should, using Exception Handling, also handle any attempt to divide by zero (ArithmeticException) value of denom instance field array. Such as: numer[0]/denom[O] and numer[1]/denom1]: etc such as 8/4 is 2 processing the rest of the numer array elements The program should display the appropriate message and then continue processing the rest of the numer array elements 5. Assume both arrays are the same length 3. Start of IntegerArrayMath class public class IntegerArrayMath int[] numer intl] denom public IntegerArrayMath(int[] a, int [] b)s numer = a denom b Example: numer is [4, 8, 15] and denom is [2, 0, 4] the resultant output would be: 4/2 is 2 Division by zero is undefined Result of 15 divided by 4 is not an integer
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