#include <iostream>
`#include <string>
using namespace std;
int main()
{
int test1, test2, test3;
int testAverage;
testAverage = (test1 + test2 + test3)/3;
cout << "Please enter your three test scores" << endl;
cin >> test1;
cin >> test2;
cin >> test3;
cout << "Your total test average is " << testAverage << endl;//my total average displays an insanly high number here as well im unsure why
if (testAverage >= 90)
cout << "Your Grade Is an A average" << endl;
else
{
if (testAverage < 90)
{
cout << "Your test average is B" << endl;
}
else if (testAverage < 80)
{
cout << "Your test average is C" << endl;
}
else
{
if (testAverage < 70)
{
cout << "Your test average is D" << endl;
}
}
}
return 0;
}
//im not sure if it is the way i nested the if statements with the brackets for i am fairly new to it, or if it is something else wrong that i am doing. Can someone can let me know why the run time error is occurring and why the math is coming out crazy, and even help me clean up my code. The question for the homework is to display a grade for the average of three test scores in a nested if statement format. P.S i believe the problem has to do with the brackets but i am unsure.
Aucun commentaire:
Enregistrer un commentaire