The program looks something like:
' ask the user for the percent markup ' get the markup, put it in a variable ' convert percent markup to a price multiplier DO ' ask the user for the wholesale price of an item ' get the price, put it in a variable ' compute and print out the retail price LOOP END
The user is asked for and
enters the markup in percent.
Now a calculation changes the markup in percent
into a rate used to multiply the wholesale price.
These things happen only once.
Now the DO
and LOOP
show which statements will be
done repeatedly.
Here is the QBasic program which follows the outline:
' Retail price calculator ' with markup entered by the user PRINT "Enter the amount of markup in percent" INPUT MARKUP LET RATE = 1 + MARKUP / 100 DO PRINT "Enter wholesale price" ' ask the user for the wholesale price INPUT WHOLESALE ' get the price, put it in a variable PRINT "Retail price:", WHOLESALE * RATE ' compute and print out the retail price LOOP END
Most of the work of the program is done in the
DO
... LOOP
.
The first three statements are done to set things up and
need to be done only once.
(We are assuming that the MARKUP
is the same for all items
so we need to enter it only once.)
The user wishes to run the program using a markup of 10%.
What do the first three statements of the new program do?
What numbers are stored in MARKUP
and RATE
?