hey i'm trying to generate numbers from 1 to 3 in a way such that

number 1 has the probability 70% being generated
number 2 has the probability of 20% of being generated
number 3 has the probability of 10% of being generated

how do i do that?? can anyone please help.

Random r=new Random();
int i=1+r.nextInt(3);

this doesn't take into account the probabilities and generates the numbers in a random way..i need to generate the numbers according to their probabilites of being generated

It wouldn't matter, since the Random class return a number between 0(inclusive) and specified number (in this case 10)(exclusive). I would put it as gen == 9 just incase someone didn't know this(or programmed it wrong), and then place an else saying that "The generated number " + gen + " does not fit into any of the above ifs". This way the programmer would know something was wrong with the generated number before they realized that the probabilities were sqewed.

First of, i didn't know where to post this question as it isn't actually programming based but yeah. sorry.. Anyway, I was going through my binary file trying to figure ...