I'm trying to generate a random numbers
between 1 and 2 using the imported math.random()
class and set the probability
for each number.
The code below set the probability
to be 1/2 for the two number each 1/2
int randomInt = (Math.random() <= 0.5) ? 1 : 2;
I want to be able to set the probability
for each individual numbers, for example number 1 (20% probability) and number 2 (80% probability) or the ratio of 20:80. any solution?
Edit : the programme i need to make is be able to set the probability for number 1 and number 2 separately. like asking the user to input the probability for number 1 and 2
Aucun commentaire:
Enregistrer un commentaire