Write a program that prompts the user to enter an integer that represents an array size. Java

Question:

Write a program that prompts the user to enter an integer that represents an array size. Java generates a Number Form at Exception if the user attempts to enter a noninteger value using next Int (). Handle this exception by displaying an appropriate error message. If the size entered is an integer, create an array of type double using the integer entered as the size. Java generates a Negative Array Size Exception if you attempt to create an array with a negative size; handle this exception by setting the array size to a default value of five. If the array is created successfully, use exception-handling techniques to ensure that each entered array value is a double. Then calculate each element’s distance from the average. Save the file as DistanceFromAverageWithExceptionHandling.java.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Java Programming

ISBN: 9780357673423

10th Edition

Authors: Joyce Farrell

Question Posted: