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 1:
public static int[] generateRandomArray(int maxValue){
}
This method should generate an array of 10 elements containing uniformly random integers between 1 and max value inclusive. (If the max value were 8, it could generate a number 1,2,3,4,5,6,7,8).
Step 1: Initialize an empty array of size 10.
Step 2: Create a loop running through each element in the array
Step 3: Within the loop use Math.random() to create a random number between 1 and max value.
Step 4: Within the loop set the specific element in the array equal to that random number
Step 5: Return the resulting array
Part Two:
Method 2:
public static void printNumberDistribution(int[] array, int maxValue){
}
This method should print out the number of instances of each number value present in the array.
Example 1: The array {4,3,5,7,8,6,6,2,4,7} will print out the following in the method
1:
2:*
3:*
4:**
5:*
6:
7:**
8:*
Example 2: The array {3,4,9,7,8,5,2,6,4,1} will print out the following in the method
1:*
2:*
3:*
4:*
5:*
6:*
7:*
8:*
9:*
Step 1: Create a for loop running from 1 to MaxValue
Step2: In for loop 1 Print the current number were on
Step 3: In for loop 1Create another for loop running through each element in the array
Step 4: In both for loops check to see if the element in the 2nd for loop is equal to the current number were on
Step 5: If thats true print *
Step 6: Outside of loop2 but inside of loop1 print a new line
this is the code given
import java.util.Scanner;
public class Firstname_Lastname_WK11Lab3{
//Purpose: public static int[] generateRandomArray(int maxValue){//implement method 1 here return null; }
/Purpose: public static void printNumberDistribution(int[] array){//implement method 2 here } public static void main(String[] args){ Scanner scnr = new Scanner(System.in); System.out.println("Enter the max value for the array here"); int maxValue = scnr.nextInt(); int[] numbers = generateRandomArray(maxValue); printNumberDistribution(numbers); }}

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 Programming Questions!