Question: Write a public static method named lessThanAverage that will take an ArrayList as an argument. This method will return an ArrayList. When called and passed


Write a public static method named lessThanAverage that will take an ArrayList as an argument. This method will return an ArrayList. When called and passed anArrayList, this method will return an ArrayList containing all the elements in the argument ArrayList that are less than the average of all the values in the argument ArrayList. The values in the returned ArrayList must be in the same order as they are in the argument ArrayList. Here are some examples: Example 1 Given: ArrayList myList = new ArrayList(); with these values {1,2,3,4,5}; less ThanAverage(myList) should return an ArrayList with these values {1,2} Example 2 Given: ArrayList myList = new ArrayList>(); with these values {3,7,6,2,9,0,4,8}; less ThanAverage (myList) should return an ArrayList> with these values {3,2,0,4} Example 3 Given: ArrayList> myList = new ArrayList>(); with these values {1,1,1}; less ThanAverage(myList) should return an ArrayList with these values \{\} Write a public static method named lessThanAverage that will take an ArrayList as an argument. This method will return an ArrayList. When called and passed anArrayList, this method will return an ArrayList containing all the elements in the argument ArrayList that are less than the average of all the values in the argument ArrayList. The values in the returned ArrayList must be in the same order as they are in the argument ArrayList. Here are some examples: Example 1 Given: ArrayList myList = new ArrayList(); with these values {1,2,3,4,5}; less ThanAverage(myList) should return an ArrayList with these values {1,2} Example 2 Given: ArrayList myList = new ArrayList>(); with these values {3,7,6,2,9,0,4,8}; less ThanAverage (myList) should return an ArrayList> with these values {3,2,0,4} Example 3 Given: ArrayList> myList = new ArrayList>(); with these values {1,1,1}; less ThanAverage(myList) should return an ArrayList with these values \{\}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
