#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
system("CLS");
double grade, test, number, average, sum;
int counter = 1;
cout << "Enter Number of Exams Taken: ";
cin>>test;
for (number=test;number>0;number--)
{
cout << "Enter Grade for Exam "<<counter<<": " ;
counter=counter+1;
cin>>grade;
}
cout<<fixed<<showpoint;
cout << setprecision(2);
sum=sum+grade;
average=sum/test;
cout<<"The Exam Sum of "<<sum<<" divided by "<<test<<" = "<<average<<"%"<<endl;
if(average>=90)
cout<<"You have an A";
else if (average>80)
cout << "You have a B";
else if (average>70)
cout << "You have a C";
else if (average>60)
cout << "You have a D";
else if (average<60)
cout <<"You have an F";
return 0;
}
I need the calculations for sum to calculate each time I enter a grade, so if I put that I have taken 3 tests, and then enter 100, 100, 100. It would equal 300, then do the average? Right now it is either taking the sum of the last entered test grade. HELP! Thanks.