Question: This is a java program. Declare and initialize two random arrays of random numbers to the printArrays method. Implement a method called printTwoArrays that will

This is a java program. Declare and initialize two random arrays of random numbers to the printArrays method. Implement a method called printTwoArrays that will take two arrays and print them to the console, side by side. Implement a method called compareArrays that will compare two arrays to determine which array had the most "position by position" values that were greater than the other. The program should also provide for ties.
Example:
Content of array 1: 5,8,13,24,11,56,13
Content of array 2: 7,4,3,6,33,15,5
Array 1 has 5 positions with higher values than array 2, while array 2 has only 2 higher values than array 1. There are no ties.
-Declare two arrays of int data type. The size should be declared using a variable called elements. The program should run with thie variable set ti any value.
-Initialize each array. The arguments for the limits for the random range should be defined by the variables low_limit and high_limit. These two variables should be passed to the methods to initialize the array.
-Implement a new method that takes two arrays as arguments, print them in rows and columns, with all integers right justified so that the units place of all numbers in a column are aligned. The method must be called printTwoArrays(..).
-Implementa new method that will count the number of times each array has the higher number when an element by element comparison is done. It will then print out the results of this comparison. The method should be called compareArrays(...) and it should take two arrays of equal length and return nothing. The example below shows the required format of the output given the arguments specified.
Elements<--8
low_limit <--40
high_limit <--90
Index 0: 7486
Index 1: 7543
Index 2: 5340
Index 3: 8046
Index 4: 6565
Index 5: 8782
Index 6: 5183
Index 7: 7542
Array 1 has 5 highs
Array 2 has 2 highs
There are 1 ties
The program should keep running until there is at least one tie.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!