You wrote an application named DistanceFromAverage that allows a user to enter up to 20 double values
Question:
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 fromthe average. Now,modify that programto 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.
Step by Step Answer:
import javautil public class DistanceFromAverageWithExceptionHandling public static void main String ...View the full answer
Students also viewed these Computer science questions
-
Design a program that allows a user to enter any quantity of numbers until a negative number is entered. Then display the highest number and the lowest number.
-
An experimental addition to UNIX allows a user to connect a watchdog program to a file. The watchdog is invoked whenever a program requests access to the file. The watchdog then either grants or...
-
Write a program named TemperaturesComparison that allows a user to input five daily Fahrenheit temperatures that must range from ?30 to 130; if a temperature is out of range, require the user to...
-
In an effort to check the quality of their cell phones, a manufacturing manager decides to take a random sample of 10 cell phones from yesterdays production run, which produced cell phones with...
-
The total weights of garbage that households discard weekly is approximately normally distributed, with a mean of 12.5 kg and a standard deviation of 5.7 kg (based on Data Set 1 in Appendix B).s a....
-
Determine whether each of the following is true or false. Assume that a, x, M, and N are positive. log a x 3 = 3 log a x
-
Why can patterns be labeled experienced reuse?
-
In the project environment, cause-and-effect relationships are almost always readily apparent. Good project management will examine the effect in order to better understand the cause and possibly...
-
PT Elyksion Communication is experiencing rapid growth. The company expects earnings and dividend growth of 15% over the next two years, 13% in the third year, and constant growth of 6% for the...
-
Use Mullers method or MATLAB to determine the real and complex roots of (a) (x) = x3 - x2 + 3x - 5 (b) (x) = 2x4 + 6x2 10 (c) (x) = x4 - 2x3 + 6x2 8x + 8
-
Write an application named BadSubscriptCaught in which you declare an array of 10 first names. Write a try block in which you prompt the user for an integer and display the name in the requested...
-
Create an ApartmentException class whose constructor receives a String that holds a street address, an apartment number, a number of bedrooms, and a rent value for an apartment. Save the file as...
-
Hank Krendle, account manager for Craven Marketing, believes that Jason Krueger is a great candidate for promotion. Jason has consistently met the expectations set for his position, has initiated...
-
Closing Entries The adjusted trial balance of the Petal Corporation, prepared as of December 31, contains the following accounts: Service fees earned Interest income Debit Credit $87,500 2,600...
-
The Corner Bakery has a debt-equity ratio of .53. The required return on assets is 13.5 percent and its cost of equity is 15.8 percent. What is the pretax cost of debt based on M&M Proposition II...
-
Enter a quadratic polynomial which has zeros at 5 and 9. Enter a quadratic polynomial which has zeros at -7 and 3. Enter a quadratic polynomial which has a double root at -10.
-
Your department has a total salary budget of $62,500. Among your employees, there is a manager who is allocated a significant portion of this budget. 4. Calculate the manager's salary, given that it...
-
Divide and completely simplify the following: x+5214 x-4 x-49 x-2
-
Why does the auditor need to ask if any equipment purchases are from a related party?
-
Stephen Schor, an accountant in New York City, advised his client, Andre Romanelli, Inc., to open an account at J. P. Morgan Chase Bank, N.A., to obtain a favorable interest rate on a line of credit....
-
You can declare variables with the same name multiple times _____________. a. Within a statement b. Within a block c. Within a method d. You never can declare multiple variables with the same name.
-
If you declare a variable as an instance variable within a class, and you declare and use the same variable name within a method of the class, then within the method, _____________. a. The variable...
-
A method variable _____________ a class variable with the same name. a. Acquiesces to b. Destroys c. Overrides d. Alters
-
Solve the triangle shown to the right. Round the lengths of sides to the nearest tenth and angles to the nearest degree. 96 b=5 a=7 B A C C9.0 (Do not round until the final answer. Then round to the...
-
Hello, need help with making the program MealData.txt Avocado Egg Rolls 6.00 Parmesan-crusted Chicken 19.75 Strawberry Shortcake Pizookie 8.25 BBQ Tri-Tip Sliders 12.95 Spicy Peanut Chicken with Soba...
-
Assume you have been appointed to develop ethnic and multicultural marketing for a small chain of household appliance stores in large metropolitan area. There are several large concentrations of...
Study smarter with the SolutionInn App