Question: In Java, write a class Statistics that implements the following public interface: Statistics main(String[] args) : void average(double[]) : double median(double[]) : double mode(double[]) :
In Java, write a class Statistics that implements the following public interface:
| Statistics |
| main(String[] args) : void |
| average(double[]) : double |
| median(double[]) : double |
| mode(double[]) : double[] |
| most(double[]) : double[] |
| Assignment: average(double[]) : double |
|
average should return the average of all the doubles in the specified array. The average of a collection of values is the sum of the values divided by the number of values in the collection.
Example:
[7, 23, 10]
(7 + 23 + 10) / 3 = 13.33
Average: 13.33
| Assignment: median(double[]) : double |
|
median should return the median value of the specified array. The median of a collection of values is the value that occurs in the middle of the collection when the collection is sorted in ascending or descending order. If the list of numbers is even, the median is the average of the two numbers occurring the middle of the collection.
Examples:
[7, 12, 13, 14, 21, 23, 23, 42, 50]
Median: 21
[7, 12, 13, 14, 21, 23, 23, 42, 50, 99]
(21 + 23) / 2 = 22
Median: 22
Note: the Statistics starter file defines a median method that sorts the specified array.
| Assignment: mode(double[]) : double[] |
|
mode should return a double[] consisting of the mode(s) of the specified array. The mode of a collection of values is the value that occurs the most in the collection. It is possible for a collection of values to have multiple modes as numbers can tie for highest number of occurrences. Half credit awarded if only one of the modes is returned.
Examples:
[13, 18, 13, 14, 13, 16, 14, 21, 13]
Mode: [13]
[13, 18, 13, 14, 13, 16, 14, 21, 14]
Mode: [13, 14]
[13, 18, 23, 14, 7, 16, 42, 21, 10]
Mode: [13, 18, 23, 14, 7, 16, 42, 21, 10]
| Assignment: most(double[]) : double[] |
|
most should return a double[] consisting of the doubles in the specified array that are greater than or equal to the average of the specified array.
Examples:
[7, 23, 10, 42]
(7 + 23 + 10 + 42) / 4 = 20.5
Average: 20.5
Most: [23, 42]
| Assignment: main(String[] args) : void |
|
main should use Scanner to obtain any number of double values from the user (first, ask the user how many values he or she will be entering), add those values to a double[], then display the average, median, mode, and most.
Sample Output
Welcome to Statistics!
This program will calculate the average, median,
mode, and most of any number of (double) values!
How many values will you be entering? 6
> Please enter value #1: 7
> Please enter value #2: 13
> Please enter value #3: 42
> Please enter value #4: 7
> Please enter value #5: 23
> Please enter value #6: 42
[7.0, 13.0, 42.0, 7.0, 23.0, 42.0]
Average: 22.333333333333332
Median: 18.0
Mode: [7.0, 42.0]
Most: [42.0, 23.0, 42.0]
Starter Files:

![Statistics main(String[] args) : void average(double[]) : double median(double[]) : double mode(double[])](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f67b26b120c_41466f67b2650f32.jpg)
Write your text here...public class ArrayHelper public static void display(int[] nums) { System.out.print("1"); for(int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
