Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started