Part 1: 25pts
Write Java static method randomArray() that gets three integers as parameters (size, lower limit and
upper limit), creates an integer array of given size, fills the array with random integer numbers from
lower limit to upper limit (both included), and returns the created and filled array.
Write Java static method printArray() that gets an array of integers as parameter, prints the elements
of the array with a space between them and 10 elements on each line.
Write Java statements that:
• input the size, the lower limit and the upper limit values,
• create an array of integers by calling the randomArray method,
• print the array by calling printArray method.
Hint: To create a random integer number between k and m (both inclusive), the following statements
may be used provided that java.util.Random is imported:
Random rand = new Random();
int a = rand.nextInt(m - k + 1) + k;
Part-1:
Enter size of array: 20
Enter lower limit: 80
Enter upper limit: 120
Array:
88 92 119 95 92 85 111 96 103 104
110 103 115 104 119 96 90 94 96 102
Part 2: 25pts
// Create Random object
// Random number k to m
Write Java static method indexMax() that gets an array of integers as parameter, returns the index of
the maximum element. If the maximum value occurs more than once, the method will return the index
of the first.
Don't use any collection or iteration class or their methods.
Write Java statements that call indexMax() method to get the index of the maximum value in the array
created in part-1, and print this index and the maximum value.
Part-2:
Index of the maximum is 2
Maximum = 119