Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Research

Authors: Alvin C. Burns, Ronald F. Bush

7th edition

0133074676, 978-0133074673

More Books

Students also viewed these Operating System questions