A. Purpose of the Program

Inserting, updating and removing items from an ArrayList

B. Required Reading

Chapter 7.13 ArrayLists

C. Exercise

Write a program that presents a menu to the user that allows basic inserting, updating and removing a list of names from an array list. Continue these options until the user enters the exit number. The program should have at least the following functions:

  • displayMenu displays the menu.
  • displayList shows the array list.

E. Example Input and Output

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 1
Enter a name
Name 1

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 1
Enter a name
Name 2

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 1
Enter a name
Name 3

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 1
Enter a name
Name 4

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 4
Names in List
[0] Name 1
[1] Name 2
[2] Name 3
[3] Name 4

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 2
Names in List
[0] Name 1
[1] Name 2
[2] Name 3
[3] Name 4
Enter a number to edit
1
Enter new Name
Name 2 new

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 4
Names in List
[0] Name 1
[1] Name 2 new
[2] Name 3
[3] Name 4

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 3
Names in List
[0] Name 1
[1] Name 2 new
[2] Name 3
[3] Name 4
Enter a number to delete
2

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 4
Names in List
[0] Name 1
[1] Name 2 new
[2] Name 4

Name List Menu
1. Add a name
2. Edit a name
3. Delete a name
4. Display names
5. Quit
Enter Choice: 5
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.