Let us generalize Section 5.8’s class-average problem. Consider the following problem:
Develop a class-averaging app that processes grades for an arbitrary number of students each time it’s run.
In the previous class-average example, the problem statement specified the number of students, so the number of grades (10) was known in advance. In this example, no indication is given of how many grades the user will enter during the app’s execution. The app must process an arbitrary number of grades. How can it determine when to stop the input of grades? How will it know when to calculate and display the class average?
One way to solve this problem is to use a special value called a sentinel ...