i need help with this code for my class

Hey for what ever reason i cant change anything in this code. i need to add an extra grade to the average and for it to say "Enter four grade for student number". when i run it it says "Enter three grade for student number" and it wont let me add an extra grade to the average i tryed adding grade4. please help thanks



#include <iostream>

#include <iomanip>

using namespace std;

char LetterGrade(double);

double Average(int, int, int,int);

int main()

{

int grade1, grade2, grade3 , grade4;

int numberofStudents;

double totalofAver = 0;

double studentaver;

cout << "enter the number of students in Class: ";

cin >> numberofStudents;

cout << setprecision(2) << fixed;

for (int i = 0; i < numberofStudents; i++)

{

cout << "Enter four grade for student number " << i + 1 << " : ";

cin >> grade1 >> grade2 >> grade3 >> grade4 >>;

cout << "\nStudent number " << i + 1 << " grades " << grade1 << " " << grade2 << " " << grade3 << " " << grade4;

studentaver = Average(grade1, grade2, grade3, grade4);

cout << " average of the grades " << studentaver << " letter grade: ";

cout << LetterGrade(studentaver);

totalofAver += studentaver;

}

cout << "\nThe class average " << totalofAver / numberofStudents;

} // end main

double Average(int g1, int g2, int g3, int g4)

{

return (g1 + g2 + g3 + g4) / 3.0;

}

char LetterGrade(double avgrade)

{

char letter;

if (avgrade >= 372 && avgrade <= 400)

letter = 'A';

else if (avgrade >= 340 && avgrade < 371)

letter = 'B';

else if (avgrade >= 280 && avgrade < 339)

letter = 'C';

else if (avgrade >= 240 && avgrade < 279)

letter = 'D';

else if (avgrade >= 0 && avgrade < 240)

letter = 'F';

else

letter = 'U';

return letter;

}
Remove the last >> on line 18.
Topic archived. No new replies allowed.