If the tax is always 5% of the TOTAL, only TOTAL is needed for input.
Here is the new version of the program:
' Improved Restaurant Bill calculator ' PRINT "Enter the total before tax:" INPUT TOTAL LET TAX = TOTAL * 0.05 ' 5 percent tax LET TIP = TOTAL * 0.15 PRINT "The tax is:", TAX PRINT "The tip is:", TIP PRINT "Please pay:", TOTAL + TAX + TIP END
(The tax on a restaurant bill in a big city can be more complicated than a percentage of the total. The previous version of the program might actually be more practical.)
Billing can get complicated. Consider a photocopy shop that has the following charges:
Say that you want to make several copies of a booklet. The booklet has a number of pages held together with one staple.
Think about writing a program that will calculate
the cost of making a given number of booklets.
What two numbers do you think should be INPUT
?