|
|
|
|
|
|
|
int TotalAbsences(
/* in */ const TableType absenteeData ) // Table of absences
// Calculates total number of absences during the entire week
// Precondition:
// absenteeData[A..F][MONDAY..FRIDAY] are assigned
// Postcondition:
// Function value == sum of all
// absenteeData[A..F][MONDAY..FRIDAY]
{
DayType day; // Loop counter
DeptType dept; // Loop counter
int total = 0; // Total absences
for (dept = A; dept <= F; dept = DeptType (dept +1))
for (day = MONDAY; day <= FRIDAY; day = DayType (day + 1))
total = total + absenteeData[dept][day];
return total;
}
//******************************************************************
void SetAsterisks(
/* out */ ChartType barChart, // Chart of percentages
/* in */ DayType day, // Chart index
/* in */ float percent ) // Percentage to chart
// Stores asterisks into column day of barChart to represent
// each 10 percent. Blanks are stored in balance of column
// Precondition:
// day is assigned && 0.0 <= percent <= 100.0
// Postcondition:
// Suppose percent, rounded to the nearest 10, equals k. Then
// all barChart[0..k-l][day] == *
// && all barChart[k..9][day] ==
{
int nearestTen; // Percent to the nearest ten
int counter; // Loop counter |
|
|
|
|
|