Need help please!

I'm trying to get it to calculate the students final grade for the class. I can't get it to work. Been trying for 2 hours, please help :)



#include <iostream>

using namespace std;

int main()
{
int average;
int classAverage;
char grade ='\0';
int grade1;
int grade2;
int grade3;
int grade4;
int grade5;
int finalGrade = grade1 + grade2 + grade3 + grade4 + grade5; // This takes the imputed grades and adds them
double yourGrade =finalGrade / 5.0; // calculates the grade that is used as the class grade


cout << "What is your grade on your first test?" << endl;
cin >> grade1;
cout << "What is your second test grade?" << endl;
cin >> grade2;
cout << "What is your third test grade?" << endl;
cin >> grade3;
cout << "What is your fourth test grade" << endl;
cin >> grade4;
cout << "What is your last test grade?" << endl;
cin >> grade5;

// sets values for each letter grade
if(yourGrade >= 90){
grade = 'A';
cout << "You have an " << grade << ", great job!" << endl;

}else if(yourGrade >= 80) {
grade = 'B';
cout << "You have a " << grade << ", but you can do better!" << endl;


}else if(yourGrade >= 70) {
grade = 'C';
cout << "You have a " << grade << ", you need to get this grade up!" << endl;


}else if(yourGrade >= 60) {
grade = 'D';
cout << "You have a " << grade << ", you're about to fail! GET YOUR GRADE UP!" << endl;


}else if(yourGrade < 60) {
grade = 'F';
cout << "You have a " << grade << ", you suck." << endl;
}



return 0;
}
The program is executed in the order of the statements, beginning at the start of main().

The lines where the average is calculated are done too early. You need to get the input from the user (cin statements) first. After the user has supplied all five values, then you are ready to calculate the average. i.e finalGrade and yourGrade can be calculated then, so move those statements so things are in the right sequence.
Thank you so much!
That worked perfectly.
Topic archived. No new replies allowed.