Question: In Java Please These are the instructions Part One: Method 1 : public static int [ ] generateRandomArray ( int maxValue ) { } This
In Java Please
These are the instructions
Part One:
Method :
public static int generateRandomArrayint maxValue
This method should generate an array of elements containing uniformly random integers between and max value inclusive. If the max value were it could generate a number
Step : Initialize an empty array of size
Step : Create a loop running through each element in the array
Step : Within the loop use Math.random to create a random number between and max value.
Step : Within the loop set the specific element in the array equal to that random number
Step : Return the resulting array
Part Two:
Method :
public static void printNumberDistributionint array, int maxValue
This method should print out the number of instances of each number value present in the array.
Example : The array will print out the following in the method
:
:
:
:
:
:
:
:
Example : The array will print out the following in the method
:
:
:
:
:
:
:
:
:
Step : Create a for loop running from to MaxValue
Step: In for loop Print the current number were on
Step : In for loop Create another for loop running through each element in the array
Step : In both for loops check to see if the element in the nd for loop is equal to the current number were on
Step : If thats true print
Step : Outside of loop but inside of loop print a new line
this is the code given
import java.util.Scanner;
public class FirstnameLastnameWKLab
Purpose: public static int generateRandomArrayint maxValueimplement method here return null;
Purpose: public static void printNumberDistributionint arrayimplement method here public static void mainString args Scanner scnr new ScannerSystemin; System.out.printlnEnter the max value for the array here"; int maxValue scnrnextInt; int numbers generateRandomArraymaxValue; printNumberDistributionnumbers;
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
