Question: (JAVA) write a program that store random number from 1 to 52 in a array Create another array, store first four number and find the

(JAVA) write a program that store random number from 1 to 52 in a array

Create another array, store first four number and find the biggest one.

Run 10000 times to see the occurences of each.

After I get the biggest number, I need help for run it 10000 times and find the occurences, please help

out put will be like this (should be increasing order)

Number: 4 Times:2

Number:5 Times:3

until 52 Number 52 Times 6XXX

import java.util.Arrays;

import java.util.Random;

public class RandomArray {

public static void main(String[] args) {

// creating Random class object to generate random numbers

Random r=new Random();

// creating two arrays

int arr[]=new int[52];

int arr2[]=new int[4];

// initialize first array with 1 to 52 random generated numbers

for(int i=0;i<52;i++)

arr[i]=r.nextInt(52-1)+1;

System.out.println("First four elements which are stored in another array are: ");

for(int i=0;i<4;i++) // storing first four numbers to second array

{

arr2[i]=arr[i];

System.out.print(arr2[i]+" ");

}

int max=arr2[0];

for(int i=1;i<4;i++)

{

// finding biggest number in second array

if(arr2[i]>max)

max=arr2[i];

}

System.out.println(" Biggest number is: "+max);

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!