i been trying to get the outcome of the grades to show a letter grade but its not working properly and i tried lots of way and still stuck.
for example, if i were to enter 90 for 5 grades and it comes to be an A and if i were to enter 5 grades of 80 it still comes out to be A. no matter how much i look at the program it seems good to me but if u guys could spot the mistake please let me know.
]#include <iostream>
usingnamespace std;
float total(int[],int);
int main()
{
constint num = 5;
int i, grade[num];
int final;
for (i = 0; i < num; i++)
{
cout << "Enter a grade: ";
cin >> grade[i];
}
cout << "\nThe average of the grades is " << total(grade,num) << endl;
{
if (final >= 90)
cout << "Your letter grade is A" << endl;
elseif (final >= 80 )
cout << "Your letter grade is B" << endl;
elseif (final >= 70)
cout << "Your letter grade is C" << endl;
elseif (final >= 60)
cout << "Your letter grade is D" << endl;
else
cout << "Your letter grade is F" << endl;
}
system("pause");
return 0;
}
float total(int grade[], int i)
{
int total=0;
int final;
for(int j=0; j<i; j++)
total = total + grade[j];
final=total/i;
return final;
}