Question: Background In this lab, we will compute the following statistical measures for randomly generated numbers. The mean of a set of numbers is the sum
Background In this lab, we will compute the following statistical measures for randomly generated numbers. The mean of a set of numbers is the sum of all values divided by the number of values. The median of a sorted set of numbers is the middle value of that set. For example, given the array {1,4,9,5, 22 ), the median is the element 9 in index 2 (remember that we start counting from 0!). Requirements Read over these requirements and answer the questions below before you begin writing your program. Create the following fields in the Statistics class. private int[] dataset Create the following methods in the Statistic dass. A l-arg constructor that takes an integer argument called Length and initializes the dataset field. Then randomizes the array using the following method. private void randomize) randomizes each of the elements in the array with an integer between 0 and 1000 and then sorts them. public double mean(Computes and returns the mean of the data set. . public int median Returns the middle element in the sorted data set. public int min) Returns the smallest element in the array. public int max() Returns the largest element in the data set. public void print Prints all of the elements in the array on a single line. The driver class should ask the user for a single natural number between 5 and 50. Note that you will need to store this value in an int variable. Then print out the data as seen in the example below. Don't worry about matching the spacing or decimal places seen in the results. Enter an array size between 5 and 50: 99 Enter an array size between 5 and 50: Enter an array size between 5 and 50: Mean value: 413.9 Median value: 405 Minimum value: 60 Maximum value: 60, 295, 339, 405, 567, 568, 663, 663
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
