1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
void table_top(const string & dashed_lines, const string & msg0, const string & msg1,
const string & msg2, const string & msg3, const string & msg4){
// Displays top of table
for(int i=0; i<47; i++){
cout << dashed_lines;
}
cout << endl;
cout << msg0 << setw(3) << " " << msg1 << setw(3) << " " << msg2 <<
setw(3) << " " << msg3 << setw(3) << " " << msg4 << endl;
for(int i=0; i<47; i++){
cout << dashed_lines;
}
cout << endl;
return;
}
void table_middle(int & students, int exam1[], int exam2[], int exam3[],
int exam_totals[], double & class_average){
// Displays middle of table
for(int i=0; i<students; i++){
cout << setw(6) << " " << i+1 << setw(3) << " " << setw(10) << left
<< exam1[i] << setw(10) << left << exam2[i]
<< setw(10) << left << exam3[i] << setw(6) << left << exam_totals[i];
if(exam_totals[i]==class_average){
cout << "=" << endl;
}
else if(exam_totals[i]>=class_average){
cout << "+" << endl;
}
else if(exam_totals[i]<=class_average){
cout << "-" << endl;
}
}
return;
}
void table_bottom(int & students, double class_average, int & lowest,
int & highest, int above_average){
// Displays bottom of table
for(int i=0; i<47; i++){
cout << "-";
}
cout << endl;
cout << "The number of students is:" << setw(14) << " "
<< students << endl;
cout << "The avg total score (rounded) is:" << setw(7) << " "
<< setprecision(0) << fixed << class_average << endl;
cout << "The maximum total score is:" << setw(13) << " "
<< highest << endl;
cout << "The minimum total score is:" << setw(13) << " "
<< lowest << endl;
cout << "Total scores at or above the avg is:" << setw(4) << " "
<< above_average << endl;
for(int i=0; i<47; i++){
cout << "-";
}
cout << endl;
return;
}
|