Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

eeBl)id-108566508-dt-content-rid-117252714 2/courses/SR283.CSC.201.01PRFA17/Arra

ID: 3601064 • Letter: E

Question

eeBl)id-108566508-dt-content-rid-117252714 2/courses/SR283.CSC.201.01PRFA17/Array ¥ VHL Central | Log in CSC 201 Computer Science I ArrayList Lab Create a class called CustomerListerArrayList with a ma in method that declares and instantiates an Arraylist of String following Strings to the ArrayList. 1 objects called customerName. Add each of the Beth . Jerry . Rick Summer Morty 2 Write for each loop (enhanced for loop) to display all the string objects on a separate new line (After printing the contents of the array, print a blank new line for formatting) 3 Add "Jessica" so that it is the 4'h name in the ArrayList. Now add "Jerry" into the third position in the list (there will be two identical strings "Jerry in the list). Write another for each loop (enhanced for loop) to display all the String objects on a separate new line. (After printing the contents of the array, print a blank new line for formatting) 4 5 Write a traditional for loop to remove "Jerry" and display the revised Array List. 6 In the comments text box in the Blackboard assignment link answer the following questions: was "Jerry" removed completely from the list? How many test cases does your program pass? 7 Upload your file Customertisterarraytist. Javato the assignment link in Blackhoard

Explanation / Answer

The code for Array List satisfying all the conditions is given below:

Code: -

import java.util.*;

class CustomerListerArrayList

{

public static void main(String[] args)

{

//Part 1

ArrayList<String> customername=new ArrayList<String>();

customername.add("Beth");

customername.add("Jerry");

customername.add("Rick");

customername.add("Summer");

customername.add("Monty");

//Part 2

Iterator itr=customername.iterator();  

while(itr.hasNext())

{  

System.out.println(itr.next());  

}

System.out.println(" ");

System.out.println(" ");

  

//Part 3

// as the list starts its index from 0, use add(index,"Value")

customername.add(2,"Jerry");

customername.add(3,"Jessica");

//Part 4

Iterator itr2=customername.iterator();  

while(itr2.hasNext())

{  

System.out.println(itr2.next());  

}

}

}

Save the file as CustomerListerArrayList.java and then using command prompt use the basic commands to compile(javac CustomerListerArrayList.java) and execute (java CustomerListerArrayList).

We are allowed to answer only 4 parts of a question, so to get the answers to the rest of your questions please post the remaining questions again.

This is all for the Question.

Thank You for using Chegg...!!!