For each of the following, create a static method with the appropriate inputs and outputs. Call...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
For each of the following, create a static method with the appropriate inputs and outputs. Call each of them in the main method. 2.1 Uniqueness Write a method called unique () which takes in a List and returns true if all the items in the List are unique. All the items are unique if none of them are the same. Return false otherwise. 2.2 All Multiples Write a method named allMultiples() which takes in a List of integers and an int. The method returns a new List of integers which contains all of the numbers from the input list which are multiples of the given int. For example, if the List is [1, 25, 2, 5, 30, 19, 57, 2, 25] and 5 was provided, the new list should contain [25, 5, 30, 25]. 2.3 All Strings of Size Write a method named allStrings Of Size() which takes in a List and an int length. The method returns a new List which con- tains all the Strings from the original list that are length characters long. For example, if the inputs are ["I", "like", "to", "eat", "eat", " 'eat" "apples", "and", "bananas"] and 3, the new list is ["eat", "eat", "eat" "and"]. 2.4 String To List of Words Write a method called stringToListOfWords() which takes in a String con- verts it into a list of words. We assumes that each word in the input string is separated by whitespace. If our input String is "Hello, world!", then the output should be ["Hello,", "world!"]. For extra credit, sanitize the String, cleaning it up so that we re- move the punctuation and other extraneous characters such that the output in the above example would become ["Hello", "world"] This method returns List . 2.5 Remove All Instances Write a method called removeAllInstances() which takes in a List and item4. The method then proceeds to remove each item in the list that matches the given item. For example, if the method is passed the List [1, 4, 5, 6, 5, 5, 2] and the Integer 5, the method removes all 5's from the List. The List then becomes [1, 4, 6, 2]. It should return nothing, since the changes the List it was provided. 5 You must test this on a input like the one I gave above, where some of the items to be removed are in successive indices.. Otherwise you will believe you have solved it, when in fact you haven't hit the brick wall for this problem yet. For each of the following, create a static method with the appropriate inputs and outputs. Call each of them in the main method. 2.1 Uniqueness Write a method called unique () which takes in a List and returns true if all the items in the List are unique. All the items are unique if none of them are the same. Return false otherwise. 2.2 All Multiples Write a method named allMultiples() which takes in a List of integers and an int. The method returns a new List of integers which contains all of the numbers from the input list which are multiples of the given int. For example, if the List is [1, 25, 2, 5, 30, 19, 57, 2, 25] and 5 was provided, the new list should contain [25, 5, 30, 25]. 2.3 All Strings of Size Write a method named allStrings Of Size() which takes in a List and an int length. The method returns a new List which con- tains all the Strings from the original list that are length characters long. For example, if the inputs are ["I", "like", "to", "eat", "eat", " 'eat" "apples", "and", "bananas"] and 3, the new list is ["eat", "eat", "eat" "and"]. 2.4 String To List of Words Write a method called stringToListOfWords() which takes in a String con- verts it into a list of words. We assumes that each word in the input string is separated by whitespace. If our input String is "Hello, world!", then the output should be ["Hello,", "world!"]. For extra credit, sanitize the String, cleaning it up so that we re- move the punctuation and other extraneous characters such that the output in the above example would become ["Hello", "world"] This method returns List . 2.5 Remove All Instances Write a method called removeAllInstances() which takes in a List and item4. The method then proceeds to remove each item in the list that matches the given item. For example, if the method is passed the List [1, 4, 5, 6, 5, 5, 2] and the Integer 5, the method removes all 5's from the List. The List then becomes [1, 4, 6, 2]. It should return nothing, since the changes the List it was provided. 5 You must test this on a input like the one I gave above, where some of the items to be removed are in successive indices.. Otherwise you will believe you have solved it, when in fact you haven't hit the brick wall for this problem yet.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
20 -101 10 in- laminate substrate Fig.2 Q2: The tool shown in Fig.2 is used in a gluing operation to press a thin laminate to a thicker substrate. If the wheels at points A and B both have 2 in...
-
Table P-20 contains quarterly sales ($MM) of The Gap for fiscal years 1980-2004. Plot The Gap sales data as a time series and examine its properties. The objective is to generate forecasts of sales...
-
Calculate tHo and tUo at 298 K and Ho at 348 K for the hydrogenation of ethyne (acetylene) to ethene (ethylene) from the enthalpyof combustion and heat capacity data in Tables 2.5 and 2.7. Assume the...
-
Refer to the data for S8-7. Compute second-year depreciation on the plane using the following methods: a. Straight-line b. Units-of-production c. Double-declining-balance 8-7 At the beginning of the...
-
Consistent Company has been paying regular quarterly dividends of $1.50 and wants to pay the same amount in the third quarter of 2011. Given the following information, (1) What is the total amount...
-
Why one of the Commonwealth bank of Australia 's bond price is $1053.13 but next year is $1045, What caused stock prices to fall? what is the credit rating for CBA's bonds?
-
Explain the time domain specifications of 2nd order system with the help of a suitable diagram. Write down the mathematical expression for each specification when STEP input signal is provided.
-
The ______________ is the probability, assuming H0 is true, of observing a value for the test statistic that is as extreme as or more extreme than the value actually observed. In Exercises 2328, fill...
-
The independent audit is important to readers of financial statements because it a. Determines how management will operate the company whose financial statements are audited. b. Measures and...
-
Which of the following best describes the reason why an independent auditor reports on financial statements? a. A management fraud will be detected by independent auditors. b. Different interests may...
-
A hypothesis test is performed at a significance level = 0.05. What is the probability of a Type I error?
-
The independent auditor lends credibility to client financial statements by a. Stating that the financial statements are stated in accordance with generally accepted auditing standards. b....
-
Compare and Contrast Mission and vision statements of Samsung and LG.
-
Why do CPA firms sometimes use a combination of positive and negative confirmations on the same audit?
-
In some speed ranges, vortices are shed from the rear of bluff cylinders placed across a flow. The vortices alternately leave the top and bottom of the cylinder, as shown, causing an alternating...
-
When a sphere of \(0.25 \mathrm{~mm}\) diameter and specific gravity 5.54 is dropped in water at \(25^{\circ} \mathrm{C}\) it will attain a constant velocity of \(0.07 \mathrm{~m} / \mathrm{s}\)....
-
A 1:8 scale model of a tractor-trailer rig is tested in a pressurized wind tunnel. The rig width, height, and length are \(W=0.305 \mathrm{~m}\), \(H=0.476 \mathrm{~m}\), and \(L=2.48 \mathrm{~m}\),...
Study smarter with the SolutionInn App