In Chapter 8, you wrote an application named DistanceFromAverage that allows a user to enter up to 20 double values and then displays each entered value and its distance from the average. Now, modify...


In Chapter 8, you wrote an application named DistanceFromAverage that allows a user


to enter up to 20 double values and then displays each entered value and its distance


from the average. Now, modify that program to first prompt the user to enter a number


that represents the array size. Java generates a NegativeArraySizeException if you


attempt to create an array with a negative size, and it creates a NumberFormatException


if you attempt to create an array using a nonnumeric value for the size. Handle these


exceptions using a catch block that displays an appropriate message. If the array is


created successfully, use exception-handling techniques to ensure that each entered


array value is a double before the program calculates each element’s distance from the


average. Save the file as DistanceFromAverageWithExceptionHandling.java.



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here