' First ask the user for how many numbers are going to be added. ' Then ask the user for each number, one by one. ' Add them up, print the sum. ' PRINT "How many numbers are to be added" INPUT HOWMANY LET SUM = 0 LET COUNT = 1 ' DO WHILE COUNT <= HOWMANY PRINT "Enter a number" INPUT NUMBER LET SUM = SUM + NUMBER LET COUNT = COUNT + 1 LOOP PRINT "The sum is", SUM END
The program illustrates many ideas:
SUM
and COUNT
out correctly.DO WHILE
to control the loop.After all of that, you may wish to relax and go to a party!! You can be in charge of the balloons.
Say that you wanted do draw 10 red balloons on the graphics screen. For now let's draw 10 red circles and forget about the balloons' string. The command
CIRCLE (centerX, centerY), radius
draws a circle with the current pen color. The center of the circle is at (centerX, centerY) and it has the specified radius. To set the pen color to red use:
COLOR 4
This command is like picking up a red pen.
The pen will stay red until another COLOR
command
changes it.
(You are not expected to remember color numbers.
Look in Chapter 5 if you want to see the list.)
Think about how you would write a program that draws 10 red balloons on the screen. You don't have to write the program yet.