PRINT "Please enter the clothing price:" INPUT PRICE ' IF PRICE >= 100 THEN PRINT "The tax is:", PRICE * 0.05 ' true branch PRINT "The Total is:", PRICE + PRICE * 0.05 ELSE PRINT "There is no tax" ' false branch PRINT "The Total is:", PRICE ' false branch END IF ' END
If the PRICE
is greater or equal to 100,
then the two statements in the
true branch are executed.
The first one prints out the tax, then the second one prints out the
total cost which is the price plus the tax.
To practice putting together programs with two-way decisions, let us write another version of the program. The story problem is the same:
A clothing store wants a program that calculates the tax on an item. Clothing that costs $100 or more has a 5% tax. Clothing that costs less than $100 is tax free. Write a program that asks for the price, then calculates the tax and prints it out, and prints out the total cost of the item.
In this new version of the program,
put all PRINT
statements after the END IF
statement.
Here is a start:
PRINT "Please enter the clothing price:" INPUT PRICE ' IF PRICE >= 100 THEN LET TAX = PRICE * 0.05 ELSE LET TAX = ____________ END IF ' PRINT "The tax is:", _______________ PRINT "The total is:",______________ END
Complete the program by filling in the blanks.