Professional Documents
Culture Documents
Example 2: Algorithm (With Line Numbers Added For The Desk Check)
Example 2: Algorithm (With Line Numbers Added For The Desk Check)
Problem Description: Calculate the discounted price of an item purchased. Customers receive a discount of
15% on an item if the purchase price of the item is over $100.
For an IF without an ELSE, if the condition evaluates to True then execution continues to the next line and the
lines between the IF and ENDIF are executed (inclusive), otherwise (the condition is False) execution jumps
from the IF to the ENDIF.
1 calcPrice()
2 Input price
6 ENDIF
7 Display price
8 STOP
Desk Check
3 Price
>100
4 200 x
15 / 100 = 30
.
5 200 – 30 =
170 .
6 Output = Price 170
7 .
8
Inputs: price = $50
Correct results: price = $50.
2 50 Price 50
3 50 <100
4
5 .
6
7 Price = 50
8