I'm trying to make a simulator for statistics and, to begin with, I want to draw a number from 0 to 2 where each has the same odds of being drawn (i.e 0 = 33.33%, 1 = 33.33% and 2 = 33.33%) but when I run my code (for a million draws) I always get 0 is drawn 33% of the time, 1 is drawn 66% and c is drawn 1%.
For a million draws, I'd expect (with some variance) that each one of the number is drawn close to 33%.
this is what I got for the code:
Random number = new Random();
int sorteio;
int a=0;
int b=0;
int c=0;
int n;
for (n=0;n<1000000;n++){
sorteio = number.nextInt(3);
switch (sorteio){
case 0:
a++;
case 1:
b++;
case 2:
c++;
}
}
System.out.println("a: " + a + " b: " + b + " c: " + c);