Due by the end of Tuesday, December 5
Create a new project L12 for the program TestStats.
Today we will be creating a class named ArrayStats. This class will be like Arrays -- a class that contains several helpful methods for working with arrays. The ArrayStats class contains several static methods that compute some statistic values of integer arrays:
You will create the class ArrayStats so that its methods work as intended.
You may use a different name for the package, or not use a package at all, but you will have to modify/delete the package line of TestStats.
For the purposes of this lab, you do not need to do any error checking on the arguments to the methods. Just get the practice creating and manipulating the arrays.
For example,
a = ArrayStats.createRandomArray(5, 10);would create an array with 5 elements containing random numbers from 1 to 10 -- possibly [5, 9, 10, 1, 1].
Hint: there's a method very much like this in the slides!
Assume that the array has at least one element.
Remember that to get the average of int values, you need to cast the sum to be a double.
Don't copy the code for summing the array. You can get the sum of the array by calling the getSum method.
(From Wikipedia -- red text added) "The median is the value separating the higher half of a data sample, a population, or a probability distribution, from the lower half. In simple terms, it may be thought of as the "middle" value of a data set when it's sorted. For example, in the data set {1, 3, 3, 6, 7, 8, 9}, the median is 6, the fourth number in the sample," while another dataset {1, 2, 3, 3, 3, 3, 4, 5, 6} has the median value of 3 (5th value)."If the array contains an even number of elements, the median is the average of the two middle order statistics. For example, for the data set (1,2,3,4), the median is (2+3)/2.0 = 2.5, while for the data set (1,2,3,3,5,5), the median is 3."
Note: The array getMedian is given might not be sorted. The median is still the value that would be in the middle if it were sorted. So the median of [6, 1, 3, 3, 7, 8, 9] is 6.
Do not change the array! If the array was not sorted beforehand, it should not be sorted after calling this method.
Hint: you're not allowed to modify the array, but you are allowed to modify a copy of the array. Check out the Arrays helper class for methods that allow you to copy and sort arrays.
Run your program several times to make sure your methods are correct.
Submit this/these files:
You will be graded on the following: