program help please!!

I am not sure what I am missing or what mistakes I have but i need my out put to look like this:

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

and here is my program;

#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;
int loop_count = 0;

cout << fixed << showpoint << setprecision(2);
cin >>section;
cin >>score;

loop_count = section;
while (loop_count == section)
{

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++;
score++;
total_scores = score + 1;
total_sections = section + 1;
loop_count = loop_count + 1;

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 << "Lowest Score: " << low_score << endl;
cout << "Highest Score: " << high_score << endl;
cout << "Total number of scores: " << total_scores << endl;
cout << "Total number of sections: " << section << endl;


cout << endl << "That's all the sections!! Normal Termination." << endl;

}

return 0;

}

It is only registering one score not all of them and its not doing the totals right.

Thank you in advance!
Hi

Please put your code in code syntax next time.

You are expected to get the section, the Lowest Score and the Highest Score as input( Even I am not sure, whether it is so, please write the purpose of your code next time)
1
2
3
cin >>section;
cin >>low_score;
cin>>high_score 


but you are doing some thing else, getting section and score,

1
2
cin >>section;
cin >>score;




for this reason the following code print on screen o :-)
1
2
cout << "Lowest Score: " << low_score << endl;
cout << "Highest Score: " << high_score << endl;


and you should add some thing like following to get the average


cout << "Average Score: " <<(high_score+low_score )/ 2.0 <<endl;

hope it helps
Last edited on
Topic archived. No new replies allowed.