I am having trouble printing out the method randTest (int n) as errors keep appearing. I want to print this method in the main as i want to print the results in a clear tabular form. The method must stay static void. This is my code below:
public class RandNumGenerator {
public static int RandInt(){
double n = Math.random()*10;
return (int) n;
}
public static void randTest(int n){
int [] counts = new int [10];
for(int i=0;i<n;i++){
counts[i] = RandInt();
System.out.println(counts[i]);
}
}
public static void main(String[] args) {
System.out.println(RandInt());
System.out.println(randTest());
}
}
Aucun commentaire:
Enregistrer un commentaire