Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prompts the user for the: output file name array size numbers in array Expected output is incouded Write an interactive program that displays statistics about

image text in transcribed
image text in transcribed
Prompts the user for the:
output file name
array size
numbers in array
Expected output is incouded
image text in transcribed
Write an interactive program that displays statistics about an array of randomly generated integers. The program will also Save the output to a file First your program should display an introduction Second your program should prompt for the name of an output file to use Now, in a loop until the user chooses to quit: s o inclusive. If the uscenters a prompt the user for a size for the array of inters. The range of value that is not in the valid range, give an error message and pota After obtaining a valid size from the sce, your program will the array will be the value previously input by the user. The inclusive any of tandem integer. These of designs should be in the range-5 to 5 Your program should the display the following on the console m ple: 12.-3.3.1.6 The numbers in the way inside square brackets and separated by co The minimum value in the way. (an int) The maximum value in the array, (an int) The sum of the numbers in the array. Canin The average of the numbers in the wounded to decimal place d The median of the numbers in the army rounded to decimal places d (The median of a sorted array of odd length is the middle ) The median of a sorted array of even length is the average of the det e es sept for this Use print for this) e rs) Your program should repeat until the user enters as the size of the amy l is a scend to quit the program) Your program will be divided into two separate java files: "Numbers.Mainjasad Numbers java Numbers. Main.java will contain a main method and methods tec Display an introduction public statie void displayIntroduction) Prompt the user for an input file name promptForFileName() Prompt the user for the size of the array public static int prompt ForArraysize() Create an output String which can be displayed on the console and sent to a fle public statie String for at statistics in numbers double average double nedan) Display an exit message public static void displayExit Message NOTE: No calculations ecrando number generation will be done anywhere in the New Main.java class NOTE: You can include additional methods to help structure your program n, int max) Numbers.java will not have a main method but will have methods to Create an array of a given size and fill it with randcenters in the ra i n public static intl get Randon IntArray int size, int Find the minimum integer in an array of inters public static int findin dintil Integers) Find the maximum integer in an array of integers public static int findintil Integers) Find the sum of all the inters in an array of inters publie statie in calculates in integers) Find the average of an array of integers public statie double calculate Average intl Integers) Find the median of an array of intepers public statie double calculate median (intl Integers) of values(-5 to 5)ora particular NOTE: Write these methods in a peneral way that does not depend on a particular range of any sizes (3608). The methods should work with an array o n Note: Numbers.java will not do any 1/0. That is, it should not have any print statements or read or write any files. It should not prompt for user input. Note: You MUST NOT change the method signatures shown above. You may provide additional methods to help structure your code if you wish. Note: The statistical calculation methods in Numbers.java must work with an unsorted array as a parameter. These methods may need to sort a copy of the numbers array to do some of the calculations, but should not alter the original array in any way. These methods should return full precision results, not rounded results, Extra Credit 5%: Also display the standard deviation of the numbers in the array. You would accomplish this by providing an additional method in Numbers.java: public static double calculateStandardDeviation (int[] integers) Here is the formula for population standard deviation: sa.length-1 (ali) - average(a) LEO stdDev(a) = a. length Sample output (user input in bold): This program prompts for an array size between 3 and 8 inclusive. The program then creates an array of that size and fills it with random integers. The program then displays statistics about the array of integers. The program also saves the output to a file. Enter the name of the output file to use : outputA.txt Enter the size of the array (3 to 8; -1 to quit): 3 Here is the random array: [1, -5, -4) Minimum value: -5 Maximum value: 1 The sum of the numbers is: -8 The average of the numbers is: -2.67 The median value is: -4.00 The standard deviation is: 3.21 Enter the size of the array (3 to 8; -1 to quit): 5 Here is the random array: (-1,-1,-4, 2, 1) Minimum value: -4 Maximum value: 2 The sum of the numbers is: -3 The average of the numbers is: -0.60 The median value is: -1.00 The standard deviation is: 2.30 Enter the size of the array (3 to 8; -1 to quit): -4 The size of the array must be 3 to 8. Please try again. Enter the size of the array (3 to 8; -1 to quit): hello Not an integer; try again. Enter the size of the array (3 to 8; -1 to quit): -1 Thanks for trying the 'Random Integer Array' program! NOTE: Notice in the output above that the array of numbers is NOT sorted. You should display the array of integers in the order in which they are randomly created

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions