Question: Write a class named SummaryStatistics, which of course means that the file name must be SummaryStatistics.java. All of the required formulas may be found in
Write a class named SummaryStatistics, which of course means that the file name must be SummaryStatistics.java. All of the required formulas may be found in Wikipedia.
Required elements:
-
Include the required academic integrity comment. Solutions which lack this comment will not be graded.
-
A private member variable for an array of type long. This is a reference variable that I will call v in the rest of this assignment.
-
A constructor that accepts a reference to an array of type int. Copy the elements from the int array into a new long array (v, and you must create this array). Store the long array reference in your private member variable from requirement #2.
-
A function named getValues(), which accepts no arguments and returns a copy of the reference that is stored in v. Choose the most appropriate return type.
-
A function named getAverage(), which accepts no arguments and returns a float value that is the average of the elements in the v array. Watch out for decimal truncation!
-
A function named getRange(), which accepts no arguments, which returns a value that is the range of the elements in v. Choose the most appropriate return type. Hint: The easy way to do this is to use two of the other functions.
-
A function named getMaximum(), which accepts no arguments and returns the value of the largest element in v. Pick the most appropriate return type.
-
A function named getMinimum(), which accepts no arguments and returns the value of the smallest element in the array. Pick the most appropriate return type.
-
A function named getStandardDeviation(), which accepts no arguments, computes the standard deviation of the values in the array v, and returns that computed value. Use the formula for a population. Pick the most appropriate return type.
-
A function named getValueAt(), which accepts an integer argument and returns the value at that index in the array. For example, if the array holds the elements (5,2,9), then getValueAt(2) will return 9. Pick the most appropriate return type.
-
A function named setValueAt(), which accepts a long argument and an int argument: the new value to store, and the index in the array at which to store the new value, in that order. For example, given setValueAt(12,1), this function would assign the value 12 to the element at index 1. Pick the most appropriate return type.
-
A function named getSum(), which accepts no arguments and returns the sum of the values in the array. Pick the most appropriate return type.
-
A function named getMedian(), which accepts no arguments and returns the median of the values in the v array. Keep in mind that there are two cases to handle here: an even number of values in v (4 or 6 or 8 etc), and an odd number of values in v (3 or 5 or 7 etc). In the even case, you will have to compute the average of the two middle values. This might result in a number that has a fractional value. Given that your return value might not be an even integer, choose the appropriate return type.
All member variables must be private and non-static. All functions must be public and non-static.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
