Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a public static method named lessThanAverage that will take an ArrayList as an argument. This method will return an ArrayList . When called
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}; lessThanAverage (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}; lessThanAverage (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 { } Helpful Info: You may want to write a main method to call and test your required method = Activate Windows Go to Settings to activate Windows 2:50 AM Problem Description and Given Info Write a public static method named allUnique 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 only in the argument ArrayList one time. 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}; allUnique (myList) should return an ArrayList with these values {1, 2, 3, 4, 5} Example 2 Given: ArrayList myList new ArrayList (); with these values {3, 2, 3, 1, 4, 2, 1, 3, 0}; allUnique (myList) should return an ArrayList with these values {4, 0} Example 3 Given: ArrayList myList new ArrayList (); with these values {1, 1, 1}; allUnique (myList) should return an ArrayList with these values { } Helpful Info: You may want to write a main method to call and test your required method = =
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here are the implementations for the lessThanAverage and allUnique methods along with a main method for testing java import javautilArrayList public c...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started