#include <iostream>
usingnamespace std;
int main()
{
int testNum;
double average;
double test;
cout << "This program will calculate your average test grade" << endl;
cout << "Please enter the number of exams you wish to average: ";
cin >> testNum;
while(testNum>0)
{
cout << "Enter a test grade: ";
cin >> test;
average=average+test;
testNum--;
}
average=average/testNum;
cout << "Your test average is: " << average << endl;
if (average<90)
cout << "You have an A in the class" << endl;
elseif(average<80)
cout << "You have a B in the class" << endl;
elseif(average<70)
cout << "You have a C in the class" << endl;
elseif(average<60)
cout << "You have a D in the class" << endl;
else
cout << "You have a F in the class" << endl;
return 0;
}
This program will calculate your average test grade
Please enter the number of exams you wish to average: 3
Enter a test grade: 80
Enter a test grade: 90
Enter a test grade: 2
Your test average is: inf
You have a F in the class