Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How would I make a program like this : Prompts the user to input the size of two arrays list1 and list 2 and inserting
How would I make a program like this :
- Prompts the user to input the size of two arrays list1 and list 2 and inserting the integers in them (by the user).
- Then, invoke a "Output" method to send the arrays as arguments and print the list1 and list2 in the method ("Output").
- Then, call another method "compare" to see if the both arrays have same elements. If both arrays have same elements, 1 must be retuned to the "compare" method, else -1 must be returned. Based on the return value (1 or -1) print if the arrays are equal or not. Note: you cannot use any build-in method to compare elements of the arrays.
- Then, Call another method "compareReverse" and send the array list1 as argument in the method "compareReverse" . In "compareReverse", see if the elements in the list1 are same, if we read (list1) the elements in the reverse order. In the "compareReverse" call a "printAnswer" method to print if the comparison (same in the reverse order or not). For example: (list 1: 2 3 3 2) will print same elements in the reverse order.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres an example of how you can create a program that follows the described steps in JavaScript javascript Prompt the user to input the size of the ar...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started