Question: 3. Write a complete Java program that provides two methods named randomInteger(arr) and lastIndexOf(arr, targetValue), the first method should generate an array of 20 random
3. Write a complete Java program that provides two methods named randomInteger(arr) and lastIndexOf(arr, targetValue), the first method should generate an array of 20 random integer numbers in the range of (1 - 15) and return a random integer number as a target value. Then pass the two arguments (array and targetValue) to the second method that will return the last index at which the target value occurs in the array. The method should return -1 if the value is not found. You may use any of the following methods to generate the random numbers: Random class Math.random Sample Output: Random Array: 7, 1, 13, 12, 6, 13, 1, 7, 3, 10, 2, 4, 13, 1, 6, 10, 1, 3, 13, 15] Random Search Key Value: 7 Element found at index: 7
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
