I have written a program that allows the user to insert scores and the program then provides the average score, the number of scores entered, the amount of each letter grade, and the highest and lowest score. I've also used a sentinal to exit. I'm new to C++ and this is only my second program. I understand it is probably redundant and I've done a lot of extra things I could have done easier but it works and it's me. The only part I'm having trouble with is listing the highest and lowest score. I'm lost! Any help would be appreciated. Here is my code:
#include<iostream>
using namespace std;
int main()
{
cout.setf(ios::fixed)
;
cout.setf(ios::showpoint);
cout.precision(2);
double score = 0;
char letterGrade;
const double A_GRADE = 89.5;
const double B_GRADE = 79.5;
const double C_GRADE = 69.5;
const double D_GRADE = 59.5;
const double F_GRADE = 49.5;
int examNumber = 0;
int aCount = 0;
int bCount = 0;
int cCount = 0;
int dCount = 0;
int fCount = 0;
double gpaTotal = 0;
const int A_GPA = 4;
const int B_GPA = 3;
const int C_GPA = 2;
const int D_GPA = 1;
const int F_GPA = 0;
while (score >= 0)
{
cout << "Please enter an exam score (negative to summarize) --> ";
cin >> score;
if (score > 100)
{
cout << "Please enter valid score (0-100) --> ";
cin >> score;
}
if( score >=A_GRADE && score <= 100 )
{
letterGrade = 'A';
aCount++;
examNumber++;
gpaTotal += A_GPA;
}
else
{
if( score >=B_GRADE && score < A_GRADE )
{
letterGrade = 'B';
bCount ++;
examNumber++;
gpaTotal += B_GPA;
}
else
{
if( score >=C_GRADE && score < B_GRADE )
{
letterGrade = 'C';
cCount ++;
examNumber++;
gpaTotal += C_GPA;
}
else
{
if( score >=D_GRADE && score < C_GRADE )
{
letterGrade = 'D';
dCount ++;
examNumber++;
gpaTotal += D_GPA;
}
else
{
if (score >= 0)
{
letterGrade = 'F';
fCount ++;
examNumber++;
gpaTotal += F_GPA;
}
}
}
}
}
}
cout << "The total number of exams entered: " << examNumber << endl;
cout << "The average GPA is: " << gpaTotal/examNumber << endl;
cout << "Number of A's: " << aCount << endl;
cout << "Number of B's: " << bCount << endl;
cout << "Number of C's: " << cCount << endl;
cout << "Number of D's: " << dCount << endl;
cout << "Number of F's: " << fCount << endl;
return 0;
}