Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

The if Statement [6/16]

This program draws 150 discs. The discs in the left third of the screen are painted in red, the discs in the right third of the screen in orange, and the ones in the middle are in blue.

Exercise:

Exercise if statement 06-1 output image

Modify this program such that the discs with a radius smaller than 40 are painted in red, the discs with a radius greater than 85 are painted in orange, and the other ones are in blue.

Solution

	if radius<40
		: mycolor = /red;
		
	if radius>85
		: mycolor = /orange;

Loading...