java math random
// Math.random() returns a random number between 0.0-0.99.
double rnd = Math.random();
// rnd1 is an integer in the range 0-9 (including 9).
int rnd1 = (int)(Math.random()*10);
// rnd2 is in the range 1-10 (including 10). The parentheses are necessary!
int rnd2 = (int)(Math.random()*10) + 1;
// rnd3 is in the range 5-10 (including 10). The range is 10-5+1 = 6.
int rnd3 = (int)(Math.random()*6) + 5;
// rnd4 is in the range -10 up to 9 (including 9). The range is doubled (9 - -10 + 1 = 20) and the minimum is -10.
int rnd4 = (int)(Math.random()*20) - 10;