- #1
uwp student
- 6
- 0
Homework Statement
We have multiple sections of a class for which we need to produce grading summaries by section. The grading summaries that we need are a count of how many students earned A’s, B’s, C's, etc., and the lowest, highest and average grade for each section. At the end of processing all sections the program will display a summary across all sections that will include the number of sections, the total number of scores and the average score across all sections.
Example:
Sample input 1
2 80 97
5 69 79 89 99 58
7 60 70 80 90 100 0 59
Sample output 1
2 80 97
Scores for section 1
A's: 1
B's: 1
C's: 0
D's: 0
F's: 0
Lowest Score: 80
Highest Score: 97
Average Score: 88.50
5 69 79 89 99 58
Scores for section 2
A's: 1
B's: 1
C's: 1
D's: 1
F's: 1
Lowest Score: 58
Highest Score: 99
Average Score: 78.80
7 60 70 80 90 100 0 59
Scores for section 3
A's: 2
B's: 1
C's: 1
D's: 1
F's: 2
Lowest Score: 0
Highest Score: 100
Average Score: 65.57
Total number of sections: 3
Total number of scores: 14
Class Average: 73.57
That's all the sections! Normal Termination.
The Attempt at a Solution
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int score; // input variable
int section = 0;
int high_score = 0; // highest score of section
int low_score = 0; // lowest score of section
float average_section = 0; // average of all scores in the section
float average_score = 0; // average scores of class
int total_sections = 0; // total number of sections
int total_scores = 0; // total number of scores
int A_count = 0;
int B_count = 0;
int C_count = 0;
int D_count = 0;
int F_count = 0;
cout << fixed << showpoint << setprecision(2);
cin >>section;
cin >>total_scores;
cin >>score;
while (section > 0)
{
if ((score >= 90) && (score <= 100)) A_count++;
score++;
if ((score >= 80) && (score < 90)) B_count++;
score++;
if ((score >= 70) && (score < 80)) C_count++;
score++;
if ((score >= 60) && (score < 70)) D_count++;
score++;
if (score < 60) F_count++;
cout << "A's: " << A_count << endl;
cout << "B's: " << B_count << endl;
cout << "C's: " << C_count << endl;
cout << "D's: " << D_count << endl;
cout << "F's: " << F_count << endl;
cout << "Total number of scores: " << total_scores << endl;
cout << endl << "That's all the sections! Normal Termination." << endl;
}
This is as far as I can get so far, I do not know how to read mutiple sections, scores and I cannot get the loop to end. Any hints or advice would be great. Thanks.