< previous page page_427 next page >

Page 427
Get Data (Inout: dataFile; Out: deptID, deptSales)
Read deptID from dataFile
IF EOF on dataFile
   Return
Read numDays from dataFile
Set deptSales = 0.0
Set day (loop control variable) = 1
WHILE day <= numDays
 Read sale from dataFile
 Add sale to deptSales
 Increment day

Print Data (In: deptID, storeNum, deptSales)
Print deptID
Print storeNum
WHILE deptSales > 250.0
 Print a 
*
 Subtract 500.0 from deptSales
Terminate current output line

We can check for mismatched department IDs in the main function by comparing the IDs before we call PrintData. We can check for too few data values by inserting tests for EOF in the GetData function. We can also add a test to the main function that tells us if the two files do not have the same number of data sets.
Assumptions: Sales do not exceed $25,000 for one department.
Here is our new design.

 
< previous page page_427 next page >