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 stepSolved in 3 steps with 1 images
- in java programming answer the following: Given an array called myArr (created as ArrayList<T>) and contains the {1,2,3,4,5,6,7}. (a) what would be the contents of this array after myArr.add(10). b) write the content of myArr after myArr.add(4, 11);arrow_forwardJava code 12. Given an existing ArrayList named contactList, find the number of contacts in the ArrayList and store it in the existing variable named numContacts.arrow_forwardconvert this code to JAVA location = [] size = [] rover = 0 def displayInitialList(location, size): global rover print("FSB# location Size") for i in range(len(location)): print(i," ",location[i]," ",size[i]) if rover<len(size)-1: print("Rover is at ",location[rover+1]) else: print("Rover is at ",location[rover]) def allocateMemory(location,size,blockSize): global rover if rover<len(size): while size[rover]<blockSize: rover+=1 if i==len(size): return False location[rover] += blockSize size[rover] -= blockSize rover+=1 return True else: return False def deallocateMemory(location,size,delLocation,delSize): i=0 while delLocation>location[i]: i+=1 location[i]-=delSize size[i]+=delSize while True: print("1. Define Initital memory\n2. Display initial FSB list\n3. Allocate memory\n4. Deallocate memory\n5. Exit") print("Enter choice: ",end="") choice = int(input()) if…arrow_forward
- JAVA you guys returned the question and said that it is a writing assignment but it is not. It is a java question, multiple-choice no coding. Please help me with this.arrow_forwardIn Java: Write a method that multiplies all elements in the array by 3 and returns it to the main method.arrow_forwardjava Create a static method that: is called repeatAll returns ArrayList of Booleans takes in a single parameter - an ArrayList of Booleans This method should modify its ArrayList parameter by repeating its ArrayList values. For example, if the parameter is (true, false, false) The modified ArrayList should be (true, false, false, true, false, false) public static void main(String[] args) { Scanner in = new Scanner(System.in); int size = in.nextInt(); ArrayList<Boolean> list = new ArrayList<>(); for(int i=0; i < size; i++) { list.add(in.nextBoolean()); } System.out.println(repeatAll(list)); } }arrow_forward
- First, implement a python class called Student. This class should store 2 variables, name and grade. Later, implement a class called Classroom. The constructor of this class should input the list of students in this classrom. This class should also contain 3 methods, add_student, remove_student and calculate_stats. As the names suggest, add_student method should input a Student object and add that to its' already existing student list, remove_student must input a full name(string) and delete the student with the provided name(you can assume no 2 students have the same full name). Finally, calculate_stats method must calculate and print the following statistics of the grades: 1. The name of the student with highest grade and the grade itself. 2. The name of the student with lowest grade and the grade itself. 3. The average gradearrow_forwardjava Create a static method that: is called appendPosSum returns an ArrayList of Integers takes one parameter: an ArrayList of Integers This method should: Create a new ArrayList of Integers Add only the positive Integers to the new ArrayList Sum the positive Integers in the new ArrayList and add the Sum as the last element For example, if the incoming ArrayList contains the Integers (4,-6,3,-8,0,4,3), the ArrayList that gets returned should be (4,3,4,3,14), with 14 being the sum of (4,3,4,3). The original ArrayList should remain unchanged. public static void main(String[] args) { Scanner in = new Scanner(System.in); int size = in.nextInt(); ArrayList<Integer> list = new ArrayList<>(); for(int i=0; i < size; i++) { list.add(in.nextInt()); } System.out.println(appendPosSum(list));arrow_forwardJava - Sort an Arrayarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education