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....
-
What is the difference between exporting and foreign direct investment? L01
-
e12.15. Firmswith high unsustainable earnings should havelow (trailing) PIE ratios. Is this correct?
-
The beginning inventory of drift boats at Heritage Float Co. and data on purchases and sales for a three-month period are as follows: Instructions 1. Record the inventory, purchases, and cost of...
-
Part II. Problems (60 points) 1. The Hartman Boat Company's bank statement for the month of November showed a balance per bank of 57,000. The company's Cash account in the general ledger had a...
-
David Austin recently purchased a chain of dry cleaners in northern Wisconsin. Although the business is making a modest profit now, David suspects that if he invests in a new press, he could...
-
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...
-
What aspects of Ron Johnsons turnaround strategy were appropriate, praiseworthy?
-
The Log Jamboree amusement park ride at Six Flags over Georgia consists of an approximately rectangular flume that is 6 ft wide and is constructed from fiberglass (ks = 0.002 in). In the low-velocity...
-
57'-8" 1. The building perimeter walls are 1'2" thick and the interior walls are 1'0" thick. Fig 1 and Fig 2 detail the linear feet of 1'2" -thick foundation walls. In addition, side B is 8'4" tall...
-
The Orpheus Chamber Orchestra is celebrating its 50 years as an orchestra this year. Read the following articles about its unique structure: The first Charlotte article is copied below, the rest just...
-
Which of the five strategies for adapting products and promotion for global markets does Monster Employ? 15-16. Which factors in the global marketing environment have challenged Monster's global...
-
Analysis of Current International Economic Environment in Switzerland 1. Develop a lead sentence for this section that introduces the key subsections 2. Economic Environment describe Switzerland...
-
Determine the proceeds of a $4200, non-interest-bearing note due August 1, 2027, discounted on March 1, 2023, at 7.5% compounded monthly.
-
a) Calculate the goodwill that was paid by Major Ltd on the acquisition of Minor Ltd. [10 marks] b) Prepare the consolidated statement of financial position for Major Ltd at 31 July 20X8. [30 marks]...
-
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
-
In 2019, Sunland Company had a break-even point of $388,000 based on a selling price of $5 per unit and fixed costs of $155,200. In 2020, the selling price and the variable costs per unit did not...
-
11. String Conversion Given a binary string consisting of characters '0's and '1', the following operation can be performed it: Choose two adjacent characters, and replace both the characters with...
-
Consider the table shown below to answer the question posed in part a. Parts b and c are independent of the given table. Callaway Golf (ELY) Alaska Air Group (ALK) Yum! Brands (YUM) Caterpillar...
Study smarter with the SolutionInn App