// Example 7.6. Program to find the grade average for each student #include "gradbook.h" int main(void) { int ReadNumStudents(void); // prototype cout << "This program finds the average for each student.\n\n"; int NumStudents; // number of students in class NumStudents = ReadNumStudents(); GradeBook grades; // grade book for a class float average; // student's average for (int student = 1; student <= NumStudents; student++) { average = grades.GetAverage(student); cout << "\nAverage for student " << student << " = " << setiosflags(ios::fixed) << setprecision(1) << average << "%\n"; } return 0; } // // Function to read and return the number of students // Pre: none // Post: The (positive) number of students was returned. // int ReadNumStudents(void) { int NumStudents; // number of students in class cout << "How many students are in the class? "; cin >> NumStudents; while (NumStudents <= 0) { cout << "The number of students must be positive.\n"; cout << "How many students are there? "; cin >> NumStudents; } return NumStudents; }