< previous page page_745 next page >

Page 745
Compute Averages (In: absenteeData; Out: average)
We can use the general algorithm we developed to sum the rows of a table. Each average is the row sum divided by 5.
Write Table (In: absenteeData, average; Inout: reportFile)
Write table headings to reportFile
// Process table by row
Set deptChar = A
FOR dept going from A through F
  Write Dept, deptChar to reportFile
  FOR day going from MONDAY through FRIDAY
    Write absenteeData[dept][day] to reportFile
    IF average[dept] > 0.0
       Set diffFromAvg = absenteeData[dept][day] - average[dept]
       Set percentDiff = diffFromAvg * 100.0/average[dept]
    ELSE
      Set percentDiff = 0.0
      IF percentDiff >= 0.0
         Write int(percentDiff + 0.5) to reportFile
      ELSE
         Write int(percentDiff - 0.5) to reportFile
  Write newline to reportFile
  Increment deptChar to next character

Calculate Summary (In: absenteeData; Out: barChart)
First, we can use either row processing or column processing to sum the entire table (in module Total Absences, which follows). We can then use column processing to sum each column, dividing the column sum by the total sum to get the percent of the total absences for each day. Next, we must put the appropriate number of asterisks into the bar chart, which we'll do in module Set Asterisks.

 
< previous page page_745 next page >