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

Write a menu-based program (see menubased.java) that allows a user to manipulate

ID: 3638976 • Letter: W

Question

Write a menu-based program (see menubased.java) that allows
a user to manipulate a list of strings. That is, you should do
the following in your "main" method:

- Create a list (object) of strings.

- Add an initial set of strings (say, 3 to 5 of them) to the
list that you created. You choose the actual strings. You
can hard-code these strings in the "add" statements that
you write.

- Start the menu-based interaction with a menu that provides
these options:

1. Show list
2. Show list in reverse order
3. Show size of list
4. Insert a string
5. Remove a string
6. Remove all strings
7. Quit

Note that for Option 4 you will need to ask the user for the
string to be added. Additionally, for Options 4 and 5 you will
need to ask the user for the position number (index).

For Options 4 and 5, protect your program against a
crash by including try/catch constructs.

Explanation / Answer

import java.util.*; import java.util.Scanner; public class MenuBasedList { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); List nameList = new ArrayList(); ListIterator it= nameList.listIterator(); int numberOfStrings; System.out.println("How many srtings do you want to add to the list ? "); numberOfStrings = keyboard.nextInt(); for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote