Question 1 Question 2

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Question 1 Question 2

Post by answerhappygod »

Question 1
Question 1 Question 2 1
Question 1 Question 2 1 (72.15 KiB) Viewed 43 times
Question 2
Question 1 Question 2 2
Question 1 Question 2 2 (80.71 KiB) Viewed 43 times
Write a public static method named less ThanAverage that will take an ArrayList<Integer> as an argument. This method will return an ArrayList<Integer>. 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<Integer> myList = new ArrayList<Integer>(); with these values {1, 2, 3, 4, 5}; lessThanAverage (myList) should return an ArrayList<Integer> with these values {1, 2} Example 2 Given: ArrayList<Integer> myList = new ArrayList<Integer>(); with these values {3, 7, 6, 2, 9, 0, 4, 8}; less ThanAverage (myList) should return an ArrayList<Integer> with these values {3, 2, 0, 4}
Write a public static method named inBoth that will take two ArrayList<Integer> arguments. This method will return an ArrayList<Integer>. When called and passed two ArrayList arguments, this method will return an ArrayList containing all the elements that are in both argument ArrayList objects. There should be no duplicate values in the returned ArrayList, and the values in the returned ArrayList must be in the same order as they are in the first argument ArrayList. Here are some examples: Example 1 Given: ArrayList<Integer> list1 with these values {1, 2, 3, 4, 5} ArrayList<Integer> list2 with these values {0, 2, 9, 3} inBoth (myList) should return an ArrayList<Integer> with these values {2, 3} Example 2 Given: ArrayList<Integer> list1 with these values {3, 1, 2, 3, 5, 1, 0} ArrayList<Integer> list2 with these values {0, 2, 9, 3, 5, 5} inBoth (myList) should return an ArrayList<Integer> with these values {3, 2, 5, 0}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply