4.9 Formulating Algorithms: Counter-Controlled Iteration
To illustrate how algorithms are developed, we solve two variations of a problem that averages student grades. Consider the following problem statement:
A class of ten students took a quiz. The grades (integers in the range 0–100) for this quiz are available to you. Determine the class average on the quiz.
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 grade, keep track of the total of all grades input, perform the averaging calculation and print the result.
Pseudocode Algorithm with Counter-Controlled Iteration
Let’s use pseudocode to list the actions to execute and specify ...
Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.