Learn to Program with ZedLX

Free Online Programming Course for Beginners

Variables [8/14]

This program chooses a random point. Then it draws 22 circles around it with a random radius of up to 190.
[Run the program]

Note: In each of the exercises, make sure to include any changes made in the previous exercises, as each exercise builds upon the previous ones. When you have completed an exercise, always run the program to see the results.

Exercises:

1. Move the first statement of the program (#num x ...) inside the for loop. Make it the first statement of the loop.

2. Add a println statement just above the sleepMs statement that prints out the coordinate x.

Solution

println x;

3. Modify the println statement such that prints out both the coordinates x and y, separated by a space.

Solution

println x, " ", y;

4. Modify the println statement so that it prints out the coordinates in the form (x, y) - for example, like: (321, 456).

Solution

println "(", x, ", ", y, ")";

5. Make the program draw 60 circles instead of 22. [Run the program]

6. Move the first statement of the program (#num y ...) inside the for loop. Make it the first statement of the loop.

Loading...