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:

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[])

Write your text here...public class ArrayHelper public static void display(int[] nums) { System.out.print("1"); for(int i = 0; i max) max = nums[i]; return max; } Il returns the largest element in nums public static double max(double[] nums) { double max = nums[@]; for(int i = 1; i max) max = nums[i]; return max; } // returns the smallest element in nums public static int min(int[] nums) { int min = nums[@]; for(int e : nums) if(e = 0) { int[] sub = subarray(p,i,i+1); Ilif current number is positive, create a subarray and merge it rtn = merge(rtn, sub); Il with the return int[] } } return rtn; } 1/return an int[] consisting of the integers that are unique to each of the specified int[]s public static int[] disjoint(int[] x, int[] y){ int[] rtn = new int[@]; I/ creates new return int[] of length @ for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!