Lid |
|
het was het niet maar toch thnx
code
public class Simulatie
{
public static int gooi()
{
int ogen;
ogen=(int)(1+6*Math.random());
return ogen;
}
public static int gooi2()
{
int ogen;
ogen=(int)(1+6*Math.random());
return ogen;
}
public static void main(String[] args)
{
int[] numbers = createArray();
System.out.println("SIMULATIE door NORBERT SCHILD");
System.out.println("_______________________________");
System.out.print("de simulatie zorgde voor het volgende resultaat\n");
displayArray(numbers);
int[] counts = countNumbers(numbers);
System.out.println("" );
displayCounts(counts,numbers);
}
public static int[] createArray()
{
int[] numbers= new int[100];
for(int i=0;i< numbers.length; i++)
numbers[i] = gooi()+gooi2();
return numbers;
}
public static void displayArray (int[] numbers)
{
for(int i=0;i< numbers.length; i++)
{
if ((i +1)%20 ==0)
System.out.println(numbers[i]+", ");
else
System.out.println(numbers[i]+",");
}
}
public static int[] countNumbers(int[] numbers)
{
int[] counts = new int[13];
for (int i =0;i <numbers.length; i++)
counts[numbers[i]+0]++;
return counts;
}
public static void displayCounts(int[] counts,int[] numbers)
{
for (int i =2;i <counts.length; i++)
{
if (counts[i]<100)
System.out.println(counts[i] + " keer " + i /*+(numbers[i - 1])*/);
else
System.out.println("");
//System.out.println(counts[i] + " keer " +(numbers[i + 1]+""));
}
}
}
public class Simulatie { { int ogen; ogen=(int)(1+6*Math.random()); return ogen; } { int ogen; ogen=(int)(1+6*Math.random()); return ogen; } public static void main (String [] args ) { int[] numbers = createArray(); System.out .println ("SIMULATIE door NORBERT SCHILD"); System.out .println ("_______________________________"); System.out .print("de simulatie zorgde voor het volgende resultaat\n"); displayArray(numbers); int[] counts = countNumbers(numbers); displayCounts(counts,numbers); } public static int [] createArray () { int[] numbers= new int[100]; for(int i=0;i< numbers.length; i++) numbers[i] = gooi()+gooi2(); return numbers; } public static void displayArray (int [] numbers ) { for(int i=0;i< numbers.length; i++) { if ((i +1)%20 ==0) System.out .println (numbers [i ]+", "); else System.out .println (numbers [i ]+","); } } public static int [] countNumbers (int [] numbers ) { int[] counts = new int[13]; for (int i =0;i <numbers.length; i++) counts[numbers[i]+0]++; return counts; } public static void displayCounts (int [] counts ,int [] numbers ) { for (int i =2;i <counts.length; i++) { if (counts[i]<100) System.out .println (counts [i ] + " keer " + i /*+(numbers[i - 1])*/); else //System.out.println(counts[i] + " keer " +(numbers[i + 1]+"")); } } }
Citaat: Rensjuh edit:
Codetags gebruiken! |