Write a program named Lab20A that creates an ArrayList of random numbers and processes the list....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program named Lab20A that creates an ArrayList of random numbers and processes the list. Create a void method that receives an ArrayList of integers as a parameter and will do the following: i. Print the received ArrayList with a label stating that it is the original list ii. Create a new ArrayList named list1 that is a copy of the received ArrayList (The clone method from the video sample code could be a good way to do this. This way you will not change the original ArrayList.) iii. Create a new ArrayList named list2 that contains (0,10,20,30,40,50,60,70,80,90,100) Use this statement (and add it to your notes): ArrayList list2 = new ArrayList (Arrays.asList(0,10,20,30,40,50,60,70,80,90,100)); iv. Use the contains method to see if list1 contains 50 and print a statement to say if it does or not. v. Use the removeAll method to remove all the items from list1 that are in list2 vi. Print list1 with a label to say that the items from list2 have been removed Create an int method that receives an ArrayList of integers as a parameter and will: i. Use an iterator object to go through the ArrayList and total the values ii. Calculate and return the average of the values In the main method, i. Declare an ArrayList of integers ii. Fill the ArrayList with 20 random numbers between 0 and 100 iii. Call your first (void) method sending the ArrayList iv. Call your second (int) method sending the ArrayList and print the value it returns (with a label) v. Sort the ArrayList (using Collections.sort) vi. Print the ArrayList again Write a program named Lab20A that creates an ArrayList of random numbers and processes the list. Create a void method that receives an ArrayList of integers as a parameter and will do the following: i. Print the received ArrayList with a label stating that it is the original list ii. Create a new ArrayList named list1 that is a copy of the received ArrayList (The clone method from the video sample code could be a good way to do this. This way you will not change the original ArrayList.) iii. Create a new ArrayList named list2 that contains (0,10,20,30,40,50,60,70,80,90,100) Use this statement (and add it to your notes): ArrayList list2 = new ArrayList (Arrays.asList(0,10,20,30,40,50,60,70,80,90,100)); iv. Use the contains method to see if list1 contains 50 and print a statement to say if it does or not. v. Use the removeAll method to remove all the items from list1 that are in list2 vi. Print list1 with a label to say that the items from list2 have been removed Create an int method that receives an ArrayList of integers as a parameter and will: i. Use an iterator object to go through the ArrayList and total the values ii. Calculate and return the average of the values In the main method, i. Declare an ArrayList of integers ii. Fill the ArrayList with 20 random numbers between 0 and 100 iii. Call your first (void) method sending the ArrayList iv. Call your second (int) method sending the ArrayList and print the value it returns (with a label) v. Sort the ArrayList (using Collections.sort) vi. Print the ArrayList again
Expert Answer:
Answer rating: 100% (QA)
Here is the program named Lab20A that creates an ArrayList of random numbers and processes the list java import javautilArrayList import javautilArray... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Display the information about the managers and clerks from the column Job in the table emp, order the result by deptno. EMPNO ENAME 7369 SMITH 7499 ALLEN 7521 WARD 7566 JONES 7654 MARTIN 7698 BLAKE...
-
The mass spectra of 1-methoxybutane, 2-methoxybutane, and 2-methoxy-2-methylpropane are shown in Figure 13.7. Match the compounds with the spectra. 100 73 80 S 60 57 20 0 10 20 30 40 50 60 70 80 90...
-
Ten thousand dollars is deposited in a savings account at 4.6% interest compounded continuously. When will the balance triple? O within a year of investment. O In 10 years approximately. none of the...
-
Pear Company (PC) had been renting its office building for several years. On January' 1, 2013 it decided to have a new office building constructed. On that date, it acquired land with an abandoned...
-
In an oil refinery, an equipment is to be installed for the treatment of greenhouse gases and the reduction of emissions. The company requires installing the equipment due to pressure from the...
-
The steel bar AB of the frame is assumed to be pin connected at its ends for \(y-y\) axis buckling. If \(P=18 \mathrm{kN}\), determine the factor of safety with respect to buckling. Take...
-
Weighted-average method, assigning costs. Bio Doc Corporation is a biotech company based in Milpitas. It makes a cancer-treatment drug in a single processing department. Direct materials are added at...
-
A wood frame structure as shown to the right. The framingconsists of 2x6 studs, a single 2x6 bottom plate, two 2x6 topplates and a 2x10 joist. The studs are spaced at 16 in. on centerand sheathed...
-
The unadjusted trial balance that you prepared for PS Music at the end of Chapter 2 should appear as follows: PS Music UNADJUSTED TRIAL BALANCE July 31, 2016 ACCOUNT TITLE DEBIT CREDIT 1 Cash...
-
6. Suppose the plates of a square parallel-plate capacitor are placed 2.0mm apart. If the area of each plate is 0.5cm, how many excess electrons will be on the negative plate if a voltage of 1.5V is...
-
Knowing the specific heat of ice and water is 2.05KJ/kg o C and 4.18kJ/kgC. What is the heat needed to change 2kg of ice at -20 C into 100 C water?
-
A 2.00 m rod is rotating with an oscillating angular momentum given by sin(2.00) . If a small rocket with oscillating linear momentum 10.0cos(2.00) is fired at =0.00 s , at what time will it need to...
-
3. If a proton is launched at a 2.0mm glass sphere with a velocity of 2.0 107 m/s, how might the sphere be charged such that the proton just makes it to its surface.
-
4. As the chapter states, GDP does not include the value of used goods that are resold. Why would including such transactions make GDP a less informative measure of economic well-being? 5. Below are...
-
Susan wants to buy a house for $200,000. US Bank will give her the loan at 3.5% for 30 years if she puts 20% down and Dacotah Bank will give her the loan at 3.8% for 30 years if she puts 10% down....
-
A Bloomberg Businessweek subscriber study asked, In the past 12 months, when traveling for business, what type of airline ticket did you purchase most often? A second question asked if the type of...
-
The inversion point of a gas can be mathematically expressed as (a) \(T_{i}=\frac{2 a b}{R}\) (b) \(T_{i}=\frac{2 b}{R a}\) (c) \(T_{i}=\frac{2 a}{R b}\) (d) None of these.
-
Residual free energy is defined as (a) \(G^{R}=G-G^{\mathrm{ig}}\) (b) \(G^{R}=G^{\mathrm{ig}}-G\) (c) \(G^{R}=G+G^{\mathrm{ig}}\) (d) None of these.
-
Departure functions are useful to calculate the thermodynamic property of real fluids (a) When the \(P-V-T\) data of the substance is unavailable (b) When the \(P-V-T\) data of the substance is...
Study smarter with the SolutionInn App