Exercise 2.4
- Write statements that will make the int variable number
take on a random value distributed over the given set.
- {1, 2, 3, ..., 10}
- {1, 2, 3, ..., 54}
- {5, 10, 15, ..., 100}
- {-5, -4, -3, ..., 5}
- {100, 110, 120, ..., 300}
- {a, a + b, a + 2b, ..., a + kb} where a, b,
k are integers
- Write statements that will assign the real variable randReal a random
value from the set
{1.00, 1.25, 1.50, ..., 4.00}.
- Write a program that draws red blocks (red space characters) at three random
locations on the screen.
- Write a program that draws an 8 x 2 rectangle at a random location on
the screen in a random colour.
|
|