Fill in the boxes to produce expressions that will generate random numbers in the provided ranges.
Assume that the following Random
variable has been declared:
Random rand = new Random();
Example: a random integer from 1 to 5 inclusive: |
rand.nextInt(5)
+
1
|
a random integer from 0 to 3 inclusive: |
rand.nextInt(4)
|
a random integer from 5 to 10 inclusive: |
rand.nextInt(6)
+
5
|
a random integer from -4 to 4 inclusive: |
rand.nextInt(9)
-
4
|
a random even integer from 16 to 28 inclusive: (Hint: To get only even numbers, scale up.) |
rand.nextInt(7)
*
2
+
16
|