This section and Section 4.7 solve two variations of a class average problem. Consider the following problem statement:

*A class of ten students took a quiz. The grades (0 to 100) for this quiz are available to you. Calculate and display the total of the grades and the class average.*

The class average is equal to the sum of the grades divided by the number of students. The algorithm for solving this problem on a computer must input each of the grades, calculate the average and print the result. We use **counter-controlled repetition** to input the grades one at a time.

This section presents a version of class `GradeBook`

(Figs. 4.6–4.7) that implements the algorithm in a C++ member function, and an application (

Start Free Trial

No credit card required