|
|
|
|
|
|
|
Total Absences (In: absenteeData) Out: Function value$ 20S:Level 2 |
|
|
|
|
|
|
|
|
Set total = 0
FOR dept going from A through F
FOR day going from MONDAY through FRIDAY
Add absenteeData[dept][day] to total
Return total |
|
|
|
|
|
|
|
|
|
Set Asterisks (In: day, percent; Out: barChart) |
|
|
|
|
|
|
|
|
The number of asterisks needed in the bar chart can be used as an index to tell us how many blanks and how many asterisks to store in a column. For example, if Monday had 38 percent of the absences, we would fill the first column as shown in Figure 13-15. We show the array column upside down because we'll be printing it that way. |
|
|
|
|
|
|
|
|
Set nearestTen = int(percent/ 10.0 + 0.5)
FOR counter going from 9 down through nearestTen
Set barChart[counter][day] =
FOR counter going from nearestTen - 1 down through 0
Set barChart[counter][day] = * |
|
|
|
|
|
|
|
|
|
Write Bar Chart (In: barChart; Inout: reportFile)$ 20S:Level 1 |
|
|
|
|
|
|
|
|
We can use row processing to print the bar chart with appropriate headings. Note, however, that the array barChart needs to be printed upside down. We have used the index to correspond to one less than the nearest 10 percent. Therefore, we have to print from row 9 down to row 0 to display the chart in the usual form. |
|
|
|
|
|
|
|
|
Write chart headings to reportFile
FOR counter going from 9 down through 0
Write counter + 1, 0% to reportFile
FOR day going from MONDAY through FRIDAY
Write barChart[counter][day] to reportFile
Write newline to reportFile |
|
|
|
|
|
|