Unit 3 - Using Algorithm and Flowchart in programming
Class average Algorithm
Problem: Calculate and report the grade-point average for a class.
Discussion: The average grade equals the sum of all grades divided by number of students. We need a loop to read and then add (accumulate) the grades for each student in the class. Inside the loop, we also need to total (count) the number of students in the class.
Input: Students grades
Processing: Find the sum of the grades; count the number of students; calculate average grades = sum of grades / number of students.
Output: Average grade.
Problem: Calculate and report the grade-point average for a class.
Discussion: The average grade equals the sum of all grades divided by number of students. We need a loop to read and then add (accumulate) the grades for each student in the class. Inside the loop, we also need to total (count) the number of students in the class.
Input: Students grades
Processing: Find the sum of the grades; count the number of students; calculate average grades = sum of grades / number of students.
Output: Average grade.
No comments:
Post a Comment