Question: Write a public static void method named printStatistics which takes a single parameter of an ArrayList of Integer objects. The method should print the Sum,
Write a public static void method named printStatistics which takes a single parameter of an ArrayList of Integer objects. The method should print the Sum, Average and Mode of the integers in the parameter ArrayList. If there is more than one mode (i.e. two or more values appear equal numbers of times and no values appear more often), the method should print "no single mode".
For example, if the ArrayList parameter prints as [2, 5, 7, 5] the printStatistics method should produce the following output:
Sum: 19 Average: 4.75 Mode: 5
Alternatively if the ArrayList parameter prints as [1, 5, 9, 5, 1] the printStatistics method should produce the following output:
Sum: 21 Average: 4.2 Mode: no single mode
Write your printStatistics method in the U7_L3_Activity_Two class. Use the runner class to test your method but do not add a main method to your U7_L3_Activity_Two.java file or your code will not be scored correctly.
----------------------------------------------------------------------------------------------
Coding Language: JAVA
This is what I have so far:
public static void printStatistics(ArrayList
Please help with calculating mode, I'm not entirely sure how to do it. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
