Does anybody know how to make a random number thats not between 1 - 0?
Im traying to make a simple game to teach myself, and im traying to generate a random number from 1 - 11.
Thanks!
Printable View
Does anybody know how to make a random number thats not between 1 - 0?
Im traying to make a simple game to teach myself, and im traying to generate a random number from 1 - 11.
Thanks!
Once you have a random number that is between 0-1 you multiply it by 11, round down, and add one.:
double tempValue = Math.random() * maxValue;
int value = (int) Math.floor(tempValue) + 1;
Thats acually a bit more code then you need.
Works great, thanks!