Question: Create a method called SetUpArray() that does the following: 1) Creates an array of 10,000 integers. 2) Initialize the array with random numbers from 1-1000.

Create a method called SetUpArray() that does the following:

1) Creates an array of 10,000 integers.

2) Initialize the array with random numbers from 1-1000.

3) Sort the array into ascending order by calling a Java sort method or by writing your own code to sort the array.

4) Return the created array using a return statement.

Create a method called SearchArray() that searches the array for prime numbers and prints:

1) The number of occurrences of prime numbers in the array.

2) The percentage of prime numbers as compared to the total size of the array.

3) The smallest prime number found in the array.

4) The largest prime number found in the array.

5) The prime number in the array that occurs the most often (the most number of occurrences). If more than one occurs with equal frequency then output the lowest.

In your program, store all prime numbers that occur between 1-1000 in a statically allocated array called primes. Use the primes array for searching the main array. The primes array should be created in your main() method.

In your main() method do the following:

1) Create the primes array by statically allocating the array with the set of initializers.

2) Call SetUpArray().

3) Using the array returned from SetUpArray(), pass the array and the primes array as parameters to the SearchArray() method.

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