Example 10
A youth club runs a disco every Friday, Saturday and
Sunday. They sell different flavors of chips at 65c per
bag. The youth club requires a program which adds up the
total number of bags of chips of a particular flavor sold
on the three nights and calculates the total money
raised.
1. Design a Solution
Our first attempt is:
1. get information
from user
2. calculate money raised
3. print out results
Step 1 becomes:
1.1 ask user to enter
flavor of chips
1.2 read in flavor
1.3 ask user for number sold on Friday
1.4 read in number sold on Friday
1.5 ask user for number sold on Saturday
1.6 read in number sold on Saturday
1.7 ask user for number sold on Sunday
1.8 read in number sold on Sunday
Step 2 becomes:
2.1 calculate total
bags sold
2.2 calculate total money raised
Step 3 becomes:
3.1 print out flavor
3.2 print number of bags sold
3.3 print total money raised
The complete design is shown below:
|