Implementing Counter-Controlled Repetition in Class GradeBook

Class GradeBook (Figs. 4.64.7) contains a constructor (declared in line 10 of Fig. 4.6 and defined in lines 9–12 of Fig. 4.7) that assigns a value to the class’s data member courseName (declared in line 16 of Fig. 4.6). Lines 16–26, 29–32 and 35–39 of Fig. 4.7 define member functions setCourseName, getCourseName and displayMessage, respectively. Lines 42–64 define member function determineClassAverage.

Because the gradeCounter variable (Fig. 4.7, line 46) is used to count from 1 to 10 in this program (all positive values), we declared the variable as an unsigned int, which can store only non-negative values (that is, 0 and higher). Local variables total (Fig. 4.7, line 45), grade ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.