Write a public static method named lessThanAverage that will take an ArrayList as an argument. This...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a public static method named lessThanAverage 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}; lessThanAverage (myList) should return an ArrayList<Integer> with these values {3, 2, 0, 4} Example 3 = Given: ArrayList<Integer> myList new ArrayList<Integer>(); with these values (1, 1, 1}; less ThanAverage (myList) should return an ArrayList<Integer> 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<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 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<Integer> myList new ArrayList<Integer>(); with these values {1, 2, 3, 4, 5}; allUnique (myList) should return an ArrayList<Integer> with these values {1, 2, 3, 4, 5} Example 2 Given: ArrayList<Integer> myList new ArrayList<Integer>(); with these values {3, 2, 3, 1, 4, 2, 1, 3, 0}; allUnique (myList) should return an ArrayList<Integer> with these values {4, 0} Example 3 Given: ArrayList<Integer> myList new ArrayList<Integer>(); with these values {1, 1, 1}; allUnique (myList) should return an ArrayList<Integer> with these values { } Helpful Info: • You may want to write a main method to call and test your required method = = Write a public static method named lessThanAverage 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}; lessThanAverage (myList) should return an ArrayList<Integer> with these values {3, 2, 0, 4} Example 3 = Given: ArrayList<Integer> myList new ArrayList<Integer>(); with these values (1, 1, 1}; less ThanAverage (myList) should return an ArrayList<Integer> 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<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 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<Integer> myList new ArrayList<Integer>(); with these values {1, 2, 3, 4, 5}; allUnique (myList) should return an ArrayList<Integer> with these values {1, 2, 3, 4, 5} Example 2 Given: ArrayList<Integer> myList new ArrayList<Integer>(); with these values {3, 2, 3, 1, 4, 2, 1, 3, 0}; allUnique (myList) should return an ArrayList<Integer> with these values {4, 0} Example 3 Given: ArrayList<Integer> myList new ArrayList<Integer>(); with these values {1, 1, 1}; allUnique (myList) should return an ArrayList<Integer> with these values { } Helpful Info: • You may want to write a main method to call and test your required method = =
Expert Answer:
Answer rating: 100% (QA)
Here are the implementations for the lessThanAverage and allUnique methods along with a main method for testing java import javautilArrayList public c... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
What pricing system is used to price the water you use at your college or university? Does this pricing system affect your behavior about water use (length of showers, etc.)? How? Could you recommend...
-
What political factors explain Indonesia's relative sluggish economic performance when compared to some of its Southeast Asian neighbors? What economic factors? Are these two related?
-
Suppose that for a random sample of 200 firms that revalued their fixed assets, the mean ratio of debt to tangible assets was 0.517 and the sample standard deviation was 0.148. For an independent...
-
Which of the following deformations are reversible and which are irreversible: (a) the deformation of a tennis ball against a racquet, \((b)\) the deformation of a car fender during a traffic...
-
Maguire Manufacturing Inc. has three divisions which are operated as profit centers.Actual operating data for the divisions listed alphabetically are as follows. Instructions(a) Compute the missing...
-
Shoprite Group continues to expand. This means that the group is slowly dominating the market. Based on this information, list FIVE (5) of Shoprite's customer needs that the retail group is...
-
During 2020, your clients, Mr. and Mrs. Howell, owned the following investment assets: Investment Assets Date Acquired Purchase Price Brokers Commission Paid at Time of Purchase 300 shares of IBM...
-
Explain why income splitting results in an overall decrease in taxes payable for the family when one spouse makes significantly more income than the other. (Different marginal tax rates) Lisa is a...
-
Image transcription text Question 27 {3 points) Suppose parent B's hourly wage rises to $75. The household's budget constraint implies that household consumption and the number of children must...
-
Chrome File Edit View History Bookmarks Profiles Tab Window Help PG Campus Unit 4 Lab Assignment - MT2 Do Homework - Unit 4 Lab As Dashboard + Mon Jan 8 1:00 PM...
-
Below is a bar chart showing the frequencies of ages for Representatives from the states of California (CA) and Florida (FL). Count of state abbrev state abbrev CA FL Less than 72.83 years Between...
-
a) Use the Quotient Rule to find the derivative of the given function. b) Find the derivative by dividing the expressions first. y= X 7 3 for x = 0
-
Write two KCL equations and one auxiliary equation for nodal analysis of the circuit below. No need to solve the equations. 2 V -+ 12 Vi V2 492 ww 13 102 2A 1 4 V 252 402
-
Prepare the bar bending schedule of the design members.
-
Refer to the table to answer the following questions. Year Nominal GDP (in billions) Total Federal Spending (in billions) Real GDP (in billions) Real Federal Spending (in billions) 2000 9,817 578...
-
Create a JavaFX application that displays something like the following picture. You should have methods for drawing a monkey face and a hand. Hear no evil See no evil Speak no evil
-
Sudoku is a popular logic puzzle that uses a 9 by 9 array of squares that are organized into 3 by 3 subarrays. The puzzle solver must fill in the squares with the digits 1 to 9 such that no digit is...
-
Derive exception classes from the class you wrote in the previous exercise. Each new class should indicate a specific kind of error. For example, InvalidHourException could be used to indicate that...
-
We are given three observations on binary choice with \(y_{1}=1, y_{2}=1, y_{3}=0\). Consider a logit model with only an intercept, \(P(y=1)=\Lambda\left(\gamma_{1} ight)\), where...
-
In this exercise, we generalize the results in Exercise 16.5. Consider a logit model with only an intercept, \(P(y=1)=\Lambda\left(\gamma_{1} ight)\), where \(\Lambda(\bullet)\) is the logistic \(c d...
-
In Example 16.3, we illustrate the calculation of the likelihood function for the probit model in a small example. In this exercise, we will repeat that example using logit instead of probit. The...
Study smarter with the SolutionInn App