Question: Problem Statement Write a program that prompts the user to input two integers n and m, each should be between 1 and 20. Your program

Problem Statement

Write a program that prompts the user to input two integers n and m, each should be between 1 and 20. Your program should use a method makeArray(...) which generates a list of random numbers between 0 and 99 and stores the first n values in one array of size (n-1) and the second set of m values in another array (m-1). Both arrays will be sorted using the method insertionSort(). The contents of the two arrays will be displayed back, to the user, before and after each array is sorted using another method displayArray().

Then you will use another method mergeArrays() to mergeall the elements from the previously created two arrays, into another array of size (n+m-1). The new 3rd array can be sorted inside the method as it gets merged, or using the method insertionSort(). The contents of the new array will be displayed back, to the user, before and after it is sorted using method displayArray().

The user is then prompted one more time to enter an integer key. Your program should then use another method binarySearch() which will search each of the 3 arrays for the key the user supplied. If the key is found, your program will display the index / position of where in the array the key is located and which of the arrays contain this number (1st, 2nd, or 3rd) array. Otherwise, if the user supplied a key that is not found in any of the arrays, then display a message indicating the key was not found anywhere in any of the arrays.A sample output is below,

Hint: You should be able to upgrade and re-use most of what you did in other assignments, or find sample code in the textbook for initializing, insert-sorting, displaying arrays, generating random numbers, and binary search. Again, please dont go out of your way to find something we havent covered in class. If it is complicated code you dont understand it you wont get credit for it.

Problem Statement Write a program that prompts the user to input two

BinarySearch2 [Java Applicationl C:Program Files Javalidk1.8.0 144 bin av For array#1, how many numbers (max 20) would you like to generate? 2 Array of 2 random numbers generated index 0 503 index 1 92 Array of the 2 random numbers sorted index 0 92 index 1 503 For array#2, how many numbers (max 20) would you like to generate? Array of 3 random numbers generated index 353 index 1 350 index 2 505 Array of the 3 random numbers sorted index 0 350 index 1 353 index 2 505 Array of the 5 merged numbers sorted. index 0 92 index 1 350 index 2 353 index 3 503 index 4 505 Now, type the integer you want to search 92 key match found in array#1 at index 0 key was NOT found in array#2 key match found in array#3 at index 0

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 Databases Questions!