Sample:
Program to calculate purchase including tax of 7%.
Field name are descriptive and in camel case. Intermediate field is neither input nor output, but is needed in
getting the output. For instance, hours and rate are input for pay, but gross pay, taxes, etc. are needed for
determining net pay.
Pencil and paper.
sub total = number of items * price
tax due = sub total * Tax
total amount due = sub total + tax
FIELD NAME
OUTPUT Total amount due totalAmountDue
INPUT Number of items purchased numberOfItems
Price of item price
CONSTANTS Tax TAX = .07(field names
of constants always in
upper case )
INTERMEDIATE Sub total subTotal
FIELD
Tax due taxdue
Algorithm:
Input: number of items, price
Processing:
subtotal = numberOfItems * price;
taxDue = subtotal * TAX;
totalAmountDue = subtotal + taxDue;
Output; write: totalAmountDue;
Desk check:
Input: number of items-10
: price - 8
Processing:
‘from above processing
subtotal = 10* 8 = 80
taxDue = 80 * TAX(.07) =5.60
totalAmountDue = 80 + 5.60 = 85.60
Output: Write: $85.60