Below are the instructions that i must follow for the code, i have done most of the code but i seem to be missing elements that make it compile correctly.
A static void method named randTest that takes a single integer argument, n. This should perform the following actions:
-
Declare an int array of 10 elements named counts. This will be used to record how often each possible value is returned by randInt.
-
Call randInt n times, each time incrementing the count of the element of counts corresponding to the value returned.
public static void randTest(int n){ int [] counts = new int [10]; int sampleSize = 10000; //int n = sampleSize; int RandNum = RandInt(); System.out.println ("Sample Size: " + sampleSize); String[] intArray = new String[] {"Value","Count","Expected","Abs Diff","Percent Diff"}; System.out.println(Arrays.toString(intArray)); for(int i=0;i<10000;i++){ counts[ RandNum ] = counts[ RandNum ] + 1; counts[i] = RandInt(); System.out.println(counts[n]); } }
The information must then be printed out into a results table like so:
Aucun commentaire:
Enregistrer un commentaire