0

Hey all I have a program that I have been working on and am having some trouble with keeping count of all the users grades. I know that now I am only counting the last grade earned for each category but I want to know how to keep count of all of them so my calculations are correct. I'm hoping someone could point me in the right direction.

```
#include <iostream>
#include <iomanip>
using namespace std;
double calcBasal (double grade)
{
for (int x = 1; x <= 18; x++)
{
cout << " Enter BASAL grade #" << x << " (out of 100):";
cin >> grade;
}
double total;
total = ((grade * 5) / 100);
cout << "Basal points: " << total << endl;
return total;
}
double calcApes (double grade2)
{
for (int x = 1; x <= 12; x++)
{
cout << " Enter APES grade #" << x << " (out of 100):";
cin >> grade2;
}
double total2;
total2 = (((grade2 * 10) / 100) * 12);
cout << "Apes points: " << total2 << endl;
return total2;
}
double calcQuiz (double grade3)
{
for (int x = 1; x <= 8; x++)
{
cout << " Enter quiz grade #" << x << " (out of 100):";
cin >> grade3;
}
double total3;
total3 = (((grade3 * 10) / 100) * 8);
cout << "Quiz points: " << total3 << endl;
return total3;
}
double calcMini (double grade4)
{
cout << "How many mini problems have you solved? ";
cin >> grade4;
double total4;
total4 = (grade4 * 2);
cout << "Mini-problems points: " << total4 << endl;
return total4;
}
double calcLetterGrade(double percentage)
{
if (percentage >= 95)
{
cout << "You got an A" << endl;
}
else if (percentage >= 90 && percentage < 95)
{
cout << "You got a A-" << endl;
}
else if (percentage >=85 && percentage < 90)
{
cout << "You got a B" << endl;
}
else if (percentage >= 80 && percentage < 85)
{
cout << "You got a B-" << endl;
}
else if (percentage >= 75 && percentage < 80)
{
cout << "You got a C" << endl;
}
else if (percentage >= 70 && percentage < 75)
{
cout << "You got a C-" << endl;
}
else if (percentage >= 65 && percentage < 70)
{
cout << "You got a D" << endl;
}
else if (percentage >= 60 && percentage < 65)
{
cout << "You got a D-" << endl;
}
else
{
cout << "You got a F" << endl;
}
return percentage;
}
int main()
{
double grade = 0, grade2 = 0, grade3 = 0, grade4 = 0, grade5, grandTotal, percentage;
grandTotal = calcBasal(grade);
grandTotal += calcApes(grade2);
grandTotal += calcQuiz(grade3);
grandTotal += calcMini(grade4);
cout << "Enter final exam grade (or a guess) (out of 100): ";
cin >> grade5;
grandTotal += grade5;
cout << "Total points: " << grandTotal << endl;
percentage = ((grandTotal / 465) * 100);
cout << "Percentage score: " << setiosflags(ios::fixed) << setprecision(4) << percentage << endl;
calcLetterGrade(percentage);
}
```