Question: JAVA L3A2 Write a public static void method named printStatistics which takes a single parameter of an ArrayList of Integer objects. The method should print

JAVA L3A2

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.

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!