' How many cans of cleaner are required for a 12 by 17 ft carpet? ' One can will clean 80 square feet ' LET SQUAREFEET = 12 * 17 PRINT "Required cans = ", SQUAREFEET / 80 END
The number of square feet in a rectangle is the product of the width and breadth, here 12 * 17. Divide the number of square feet in the carpet by the number of square feet one can of cleaner will clean to find the number of cans needed.
The program will write out:
Required cans = 2.55
Often a program calculates several things as it runs and keeps each
result in a variable.
Only at the end does the program print out everything it has calculated
by using the variables in a PRINT
statement.
Modify the previous program so that it calculates the number of
cans of carpet cleaner and stores the result in a variable
called CANS
.
Use the PRINT
statement
to print out SQUAREFEET
and
CANS
and appropriate captions.