|
|
|
|
|
|
|
// Precondition:
// absenteeData[A..F][MONDAY..FRIDAY] are assigned
// Postcondition:
// For all i, where A <= i <= F,
// average[i] == average of the values absenteeData[i][MONDAY]
// through absenteeData[i][FRIDAY]
{
DayType day; // Loop counter
DeptType dept; // Loop counter
int total; // Total absences for a department
for (dept = A; dept <= F; dept = DeptType(dept + 1))
{
total = 0;
// Compute row sum
for (day = MONDAY; day <= FRIDAY; day = DayType (day +1))
total = total + absenteeData[dept][day];
average[dept] = float(total) / 5.0;
}
}
//******************************************************************
void WriteTable(
/* in */ const TableType absenteeData, // Table of absences
/* in */ const float average[], // Average per dept.
/* inout */ ofstream& reportFile ) // Output file
// Writes a table to the report file showing percentage differences
// from the averages and original data
// Precondition:
// absenteeData[A..F] [MONDAY..FRIDAY] are assigned
// && average[A..F] are assigned
// Postcondition:
// A table has been written to reportFile with one row per
// department showing, for each day of the week, the number of
// absences and the percentage difference from the department's
// weekly average
|
|
|
|
|
|