Machine Problem #10. Write a method-oriented Java program using the concept of string ArrayList, create a dynamic ArrayList that initially asks the user to input the size of the ArrayList and input the given elements. After inputting all the values, a menu selection will be displayed for different ArrayList operations. Class Name: MethodDynamicArrayList What is the size of the ArrayList? 5 Enter the values: 12 13 14 15 16 Press the letter for specific operation. A – Adding element to List/ Add element C- Changing elements/ Set element R- Removing elements/Delete element I- Iterating elements G- get elements E- add elements in between two numbers S- Sorting elements Z - ArrayList size If Option A was chosen Type your option: A You want to add a new element. Enter the element you want to add: 12 The ArrayList elements now are: [12, 13, 14, 15, 16, 12] If Option B was chosen Type your option: C You want to change new element. Enter the index of the element you want to change: 1 Enter the new value: 100 The ArrayList elements now are: [12, 100, 14, 15, 16] 7 If Option R was chosen Type your option: R You will remove or delete the element. Enter the index of the element you want to delete: 1 The ArrayList elements now are: [12, 14, 15, 16} If Option I was chosen Type your option: I You want to iterate the ArrayList elements. The ArrayList elements are: [12, 13, 14, 15, 16} If Option G was chosen You want to get the ArrayList elements. The ArrayList elements are: 12 13 14 15 16 If Option E was chosen You want to add elements in between two numbers. Beginning index: 1 Ending index: 2 Enter the value of the element to be inserted: 8 The ArrayList elements are: [12, 13, 14, 8, 15, 16, 12] If Option S was chosen You want to sort the elements of the Array List The original arrangements: [12, 13, 14, 15, 16] Sorted ArrayList: [12, 13, 14, 15, 16] 8 If Option Z was chosen You want to know the size of the ArrayList The ArrayList size is: 5
Machine Problem #10. Write a method-oriented Java
ArrayList, create a dynamic ArrayList that initially asks the user to input the size of the
ArrayList and input the given elements. After inputting all the values, a menu selection will be
displayed for different ArrayList operations.
Class Name: MethodDynamicArrayList
What is the size of the ArrayList? 5
Enter the values:
12
13
14
15
16
Press the letter for specific operation.
A – Adding element to List/ Add element
C- Changing elements/ Set element
R- Removing elements/Delete element
I- Iterating elements
G- get elements
E- add elements in between two numbers
S- Sorting elements
Z - ArrayList size
If Option A was chosen
Type your option: A
You want to add a new element.
Enter the element you want to add: 12
The ArrayList elements now are:
[12, 13, 14, 15, 16, 12]
If Option B was chosen
Type your option: C
You want to change new element.
Enter the index of the element you want to change: 1
Enter the new value: 100
The ArrayList elements now are:
[12, 100, 14, 15, 16]
7
If Option R was chosen
Type your option: R
You will remove or delete the element.
Enter the index of the element you want to delete: 1
The ArrayList elements now are:
[12, 14, 15, 16}
If Option I was chosen
Type your option: I
You want to iterate the ArrayList elements.
The ArrayList elements are:
[12, 13, 14, 15, 16}
If Option G was chosen
You want to get the ArrayList elements.
The ArrayList elements are:
12 13 14 15 16
If Option E was chosen
You want to add elements in between two numbers.
Beginning index: 1
Ending index: 2
Enter the value of the element to be inserted: 8
The ArrayList elements are:
[12, 13, 14, 8, 15, 16, 12]
If Option S was chosen
You want to sort the elements of the Array List
The original arrangements: [12, 13, 14, 15, 16]
Sorted ArrayList: [12, 13, 14, 15, 16]
8
If Option
Z was chosen
You want to know the size of the ArrayList
The ArrayList size is: 5
Step by step
Solved in 3 steps with 1 images