Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Coordinate System Exercises [6/11]

This program draws two lines.

Exercise Coord 7-1 output image

Exercise: Draw a green disc that has a center on the yellow line; also, the disc should be touching the pink line and the left edge of the screen.

Hint 1

What is the distance between the pink line and the left edge of the screen?

Answer

The distance between the pink line and the left edge of the screen equals 180 pixels because the entire pink line lies on the x coordinate equal to 180. The x coordinate always equals the distance from the left edge of the screen.

Hint 2

What should the radius of the green disc be equal to?

Answer

The radius of the green disc should be 90 pixels, which means that the size (diameter) of the disc equals 180 pixels.

Hint 3

The x coordinate of the green disc center must equal the radius, and the y coordinate is given by the yellow line.

Solution

disc( 90, 450, 90, /green);

Loading...