Question: Make changes in the java file according to the instruction to complete the task. Instructions : a . ( 1 Mark ) At the beginning

Make changes in the java file according to the instruction to complete the task. Instructions : a.(1 Mark) At the beginning of the main method initialize an empty array of 10 integers.
b.(2 Marks) Fill in the logic for the fillRandom method. This method should fill in your array
with random integers in the range [1,100].
c.(1 Mark) Write the logic for the swapElements method. This method will accept an array
and two indexes. It will then swap the elements at those two indexes.
d.(3 Marks) Write the logic for the reverseArray method. This method should reverse the
order of the elements in your array. You must use your swapElements method.
e.(3 Marks) Write the logic for the shuffleArray method. This method should iterate over your
array and randomly swap each element with another element in the array. Use your
swapElements method. javaFile : import java.util.Arrays;
import java.util.Random;
public class Lab01
{
public static Random r = new Random(20240112);
public static void swapElements(int[] array, int indexA, int indexB){
// Swap the elements at 2 positions in a given array
}
public static void fillRandom(int[] array){
// Fill an array with random integers
}
public static void shuffleArray(int[] array){
// Shuffle the array
}
public static void reverseArray(int[] array){
// Reverse a given array
}
public static void main(String[] args){
// Initialize array
// Declare your integer array called array here
System.out.println(Arrays.toString(array));
// Fill the array
fillRandom(array);
System.out.println(Arrays.toString(array));
// Reverse the array
reverseArray(array);
System.out.println(Arrays.toString(array));
// Shuffle the array
shuffleArray(array);
System.out.println(Arrays.toString(array));
}
}

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!