Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Next, in a separate program, create a 1-dimensional ArrayList of strings. Use a while loop to allow the user to keep inputting strings until STOP

Next, in a separate program, create a 1-dimensional ArrayList of strings. Use a while loop to allow the user to keep inputting strings until "STOP" is entered. Next, ask the user "Which index would you like to remove?", have them input a number, and then remove the item at that index from the ArrayList. Print out the list by looping through the list and printing each item one by one.

Part 2. Ask the user for a number between 1 and 6. Depending on the number, it will do one of the following:

1. Add a string to the list (This will ask the user for a string and then add it to the list)

2. Remove a string from the list (This will ask the user for a number, and then remove that index from the list)

3. Clear the list of strings

4. Remove all strings of a certain value (This will ask the user for a string and then remove all of those strings from the list)

5. Print out the current list of strings

6. Exit the program

Sample output:

>> Here are your options:

>> 1. Add

>> 2. Remove

>> 3. Clear

>> 4. Remove particular value

>> 5. Print list

>> 6. Exit

>>1

>> Please enter string to add:

>> hello

>> Here are your options:

>> 1. Add

>> 2. Remove

>> 3. Clear

>> 4. Remove particular value

>> 5. Print list

>> 6. Exit

>> 2

>> Please enter the index number of the string you would like to remove:

>> 1

>> Here are your options

>> 1. Add

>> 2. Remove

>> 3. Clear

>> 4. Remove particular value

>> 5. Print list

>> 6. Exit

>> 4

>> Which value would you like to remove?

>> string

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions