jeudi 10 décembre 2020

How to Count number of occurrences in a random array Java

I have some homework where I have to write a simple program where 1000000 randoms netween 1-100 aer generated and stored in an array. after the program has to print out the number of occurrences of 25,50 and 100. I've been trying for loops but no luck. till now I have this :

package randomnumbers;

import java.util.Random;

public class random {

        public static void main(String[] args) {
            
        
    Random r = new Random();
    int number [] = new int [1000000];
    
    
    for (int count = 0; count < number.length; count++ ) {
    
        number[count] = 1+r.nextInt(100);
        
    
        
        
        
    }
    
    

}

}




Aucun commentaire:

Enregistrer un commentaire