Question 2 (4 mark) : Modify the above program to complete the same task by replacing the array with ArrayList so that t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Question 2 (4 mark) : Modify the above program to complete the same task by replacing the array with ArrayList so that t

Post by answerhappygod »

Question 2 4 Mark Modify The Above Program To Complete The Same Task By Replacing The Array With Arraylist So That T 1
Question 2 4 Mark Modify The Above Program To Complete The Same Task By Replacing The Array With Arraylist So That T 1 (34.92 KiB) Viewed 35 times
Question 2 (4 mark) : Modify the above program to complete the same task by replacing the array with ArrayList so that the user does not need to specify the input length at first. The recursion method's first argument should also be changed to ArrayList. The user input ends up with -1 and -1 is not counted as the elements of ArrayList. REQUIREMENTS • The user input is always correct input verification is not required). • Your code must use recursion and ArrayList. • The recursion method void printNumber (ArrayList<Integer> al, int index) is a recursion one whose arguments are an positive integer ArrayList and one integer. • The main method prompts the user to enter the elements of the ArrayList myArrayList. The recursive method printNumber is then called to display the sequence of numbers in reverse order. • Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: Enter the elements of your array: 1 2 3 4 5 6-1 Your array in reverse order is: 6 5 4 3 2 1 Example 2: The elements of your array are: 25 8 12 67 -1 Your array in reverse order is: 67 12 8 5 2
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply