Question
Run the below code and Fix the errors if occur : public static int[] generateRanNums(int num) { int[] anArray = new
Run the below code and Fix the errors if occur :
public static int[] generateRanNums(int num)
{
int[] anArray = new int [num];
//1. Using Random class, generate in a for-loop 20K numbers in the range of 1 to 5000
Random myRan = new Random();
int aNum;
if (num == 10)
{
//make a 10-element array
//for-loop for generating 10 numbers between 1 & 100'
}
}
else
{
//make a 20,000 - element array
//for-loop for generating 20,000 numbers between 1 & 5000
}
return anArray;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here is the corrected code with the errors fixed java import javautilRandom public class RandomNumbe...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