Hi i am new to programming, my program is a random number generator using the math.random class and i am having issues with my code. I need to Call the randInt method n times in the randTest method, each time incrementing the count of the element counts corresponding to the value returned. Basically each time a random number is generated, the counts element increases.
This is my code so far:
public class RandNumGenerator {
public static int RandInt(){
int n = (int) Math.random()*10;
return n;
}
public static void randTest(int n){
int [] counts = new int [10];
for(int i=0;i<10;i++){
RandInt();
}
}
}
Aucun commentaire:
Enregistrer un commentaire