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 Mark At the beginning of the main method initialize an empty array of integers.
b Marks Fill in the logic for the fillRandom method. This method should fill in your array
with random integers in the range
c 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 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 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 Lab
public static Random r new Random;
public static void swapElementsint array, int indexA, int indexB
Swap the elements at positions in a given array
public static void fillRandomint array
Fill an array with random integers
public static void shuffleArrayint array
Shuffle the array
public static void reverseArrayint array
Reverse a given array
public static void mainString args
Initialize array
Declare your integer array called array here
System.out.printlnArraystoStringarray;
Fill the array
fillRandomarray;
System.out.printlnArraystoStringarray;
Reverse the array
reverseArrayarray;
System.out.printlnArraystoStringarray;
Shuffle the array
shuffleArrayarray;
System.out.printlnArraystoStringarray;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
