Question: Using java programm Q3) Using Class Arrays and Randonm Write a program that crates an array of integers of 15 elements. The program should fill
Q3) Using Class Arrays and Randonm Write a program that crates an array of integers of 15 elements. The program should fill the aray with values that are randomly selected (using the Random class) from the range 1-100. Then the program should display the elements of the array in ascending order using method sortO in class Arrays. The program then asks the user for a search key. If the search key is found in the array, then the program outputs the index of that key in the array, otherwise a message is output stating that the key was not found. Use method binarySearch ) from class Arrays to search the key in the array Example Execution (user input in green) The array of random elements is The sorted array is Enter a search key or-1 to exit: 20 3 12 6 2 30 8 75 46 10 5 20 16 1 80 26 12 3 5 6 8 10 12 16 20 26 30 46 75 80 The key 20 found in index 9 Enter a search key or -1 to exit: 7 They key 7 does not exist Enter a search key or -1 to exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
