Alright....this is a mess, but it works (compikes) correctly....how would I create a function (probably using "switch") to return a grade based on the averages found in CalculateAvg?

``````#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

double CalculateAvg (ifstream& students, string studentid[60], string fname[60], string lname[60],
int Q1[60], int Q2[60], int Q3[60], int MidTerm[60], int Q4[60],
int Q5[60], int Q6[60], int Final[60], int i);
double FindLargest(ifstream& students, string studentid[60], string fname[60], string lname[60],
int Q1[60], int Q2[60], int Q3[60], int MidTerm[60], int Q4[60], int Q5[60],
int Q6[60], int Final[60],int i);
char grade(double CalculateAvg (ifstream& students, string studentid[60], string fname[60], string lname[60],
int Q1[60], int Q2[60], int Q3[60], int MidTerm[60], int Q4[60], int Q5[60],
int Q6[60], int Final[60],int i));

void main()
{
ifstream students;
ofstream out;

string fname[60];
string studentid[60];
string lname[60];
string id[60];
int Q1[60];
int Q2[60];
int Q3[60];
int MidTerm[60];
int Q4[60];
int Q5[60];
int Q6[60];
int Final[60];
int average;

string file;

int i;

cout << "Enter name of file" << endl;
cin >> file; file += ".txt";

students.open(file.c_str());
if(students)
{
out.open("CompleteReport.txt");
out << "Student Grade Report:" << endl;
cout << fixed << setprecision(1);
out << fixed << setprecision(1);
cout << endl
<< "StudentID    LastName    FirstName   Q1     Q2     Q3     Mid    Q4      Q5     Q6     Final    Avg.    Grade"
<< endl;
cout << "--------------------------------------------------------------------------------------------"
<<endl;
out << "StudentID    LastName    FirstName   Q1     Q2     Q3     Mid    Q4      Q5     Q6     Final    Avg.    Grade"
<< endl;
out << "--------------------------------------------------------------------------------------------"
<<endl;

for (i = 0; i < 6; ++i )
{
if (students >> studentid[i] >> fname[i] >> lname[i] >> Q1[i] >> Q2[i] >> Q3[i] >> MidTerm[i]
>> Q4[i] >> Q5[i] >> Q6[i] >> Final[i])
{
cout << left << setw(13) << studentid[i] << setw(12) << fname[i] << setw(12) << lname[i] << setw(7)
<< Q1[i] << setw(7) << Q2[i] << setw(7) << Q3[i] << setw(7) << MidTerm[i] << setw(8)
<< Q4[i] << setw(7) << Q5[i] << setw(8) << Q6[i] << setw(8) << Final[i] <<
CalculateAvg (students, id, fname, lname, Q1, Q2, Q3, MidTerm, Q4, Q5, Q6, Final, i);

out << left << setw(13) << studentid[i] << setw(12) << fname[i] << setw(8) << lname[i] << setw(7)
<< Q1[i] << setw(7) << Q2[i] << setw(7) << Q3[i] << setw(7) << MidTerm[i] << setw(8)
<< Q4[i] << setw(7) << Q5[i] << setw(8) << Q6[i] << setw(8) << Final[i] <<
CalculateAvg (students, id, fname, lname, Q1, Q2, Q3, MidTerm, Q4, Q5, Q6, Final, i);

cout << endl;
}
else
{
break;
}
}
students.close();
}
}

double CalculateAvg (ifstream& students, string studentid[60], string fname[60], string lname[60],
int Q1[60], int Q2[60], int Q3[60], int MidTerm[60], int Q4[60], int Q5[60],
int Q6[60], int Final[60],int i)
{
double average1, average1a, average1b, average1c, average1d;
double average2, average2a, average2b, average2c, average2d;
double average3, average3a, average3b, average3c, average3d;
double average4, average4a, average4b, average4c, average4d;
double average5, average5a, average5b, average5c, average5d;
double average6, average6a, average6b, average6c, average6d;
double largest1, largest2, largest3, largest4, largest5, largest6;

largest1 = (Q1[i] * 2);
largest2 = (Q2[i] * 2);
largest3 = (Q3[i] * 2);
largest4 = (Q4[i] * 2);
largest5 = (Q5[i] * 2);
largest6 = (Q6[i] * 2);

average1 = ((largest2) + Q3[i] + (MidTerm[i] * 2) + Q4[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average1a = (Q2[i] + (largest3) + (MidTerm[i] * 2) + Q4[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average1b = (Q2[i] + Q3[i] + (MidTerm[i] * 2) + (largest4) + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average1c = (Q2[i] + Q3[i]+ (MidTerm[i] * 2) + Q4[i] + (largest5) + Q6[i] + (Final[i] * 3) )/ 12;
average1d = (Q2[i] + Q3[i] + (MidTerm[i] * 2) + Q4[i] + Q5[i] + (largest6) + (Final[i] * 3) )/ 12;

average2 = ((largest1) + Q3[i] + (MidTerm[i] * 2) + Q4[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average2a = (Q1[i] + (largest3) + (MidTerm[i] * 2) + Q4[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average2b = (Q1[i] + Q3[i] + (MidTerm[i] * 2) + (largest4) + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average2c = (Q1[i] + Q3[i] + (MidTerm[i] * 2) + Q4[i] + (largest5) + Q6[i] + (Final[i] * 3) )/ 12;
average2d = (Q1[i] + Q3[i] + (MidTerm[i] * 2) + Q4[i] + Q5[i] + (largest6) + (Final[i] * 3) )/ 12;

average3 = ((largest1) + Q2[i] + (MidTerm[i] * 2) + Q4[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average3a = (Q1[i] + (largest2) + (MidTerm[i] * 2) + Q4[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average3b = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + (largest4) + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average3c = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q4[i] + (largest5) + Q6[i] + (Final[i] * 3) )/ 12;
average3d = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q4[i] + Q5[i] + (largest6) + (Final[i] * 3) )/ 12;

average4 = ((largest1) + Q2[i] + (MidTerm[i] * 2) + Q3[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average4a = (Q1[i] + (largest2) + (MidTerm[i] * 2) + Q3[i] + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average4b = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + (largest3) + Q5[i] + Q6[i] + (Final[i] * 3) )/ 12;
average4c = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q3[i] + (largest5) + Q6[i] + (Final[i] * 3) )/ 12;
average4d = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q3[i] + Q5[i] + (largest6) + (Final[i] * 3) )/ 12;

average5 = ((largest1) + Q2[i] + (MidTerm[i] * 2) + Q3[i] + Q4[i] + Q6[i] + (Final[i] * 3) )/ 12;
average5a = (Q1[i] + (largest2) + (MidTerm[i] * 2) + Q3[i] + Q4[i] + Q6[i] + (Final[i] * 3) )/ 12;
average5b = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + (largest3) + Q4[i] + Q6[i] + (Final[i] * 3) )/ 12;
average5c = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q3[i] + (largest4) + Q6[i] + (Final[i] * 3) )/ 12;
average5d = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q3[i] + Q4[i] + (largest6) + (Final[i] * 3) )/ 12;

average6 = ((largest1) + Q2[i] + (MidTerm[i] * 2) + Q3[i] + Q4[i] + Q5[i] + (Final[i] * 3) )/ 12;
average6a = (Q1[i] + (largest2) + (MidTerm[i] * 2) + Q3[i] + Q4[i] + Q5[i] + (Final[i] * 3) )/ 12;
average6b = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + (largest3) + Q4[i] + Q5[i] + (Final[i] * 3) )/ 12;
average6c = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q3[i] + (largest4) + Q5[i] + (Final[i] * 3) )/ 12;
average6d = (Q1[i] + Q2[i] + (MidTerm[i] * 2) + Q3[i] + Q4[i] + (largest5) + (Final[i] * 3) )/ 12;

if ((Q1[i] <= Q2[i] && Q1[i] <= Q3[i] && Q1[i] <= Q4[i] && Q1[i] <= Q5[i] && Q1[i] <= Q6[i]) &&
(Q2[i] >= Q1[i] && Q2[i] >= Q3[i] && Q2[i] >= Q4[i] && Q2[i] >= Q5[i] && Q2[i] >= Q6[i]))
return average1;
else if ((Q1[i] <= Q2[i] && Q1[i] <= Q3[i] && Q1[i] <= Q4[i] && Q1[i] <= Q5[i] && Q1[i] <= Q6[i]) &&
(Q3[i] >= Q2[i] && Q3[i] >= Q1[i] && Q3[i] >= Q4[i] && Q3[i] >= Q5[i] && Q3[i] >= Q6[i]))
return average1a;
else if ((Q1[i] <= Q2[i] && Q1[i] <= Q3[i] && Q1[i] <= Q4[i] && Q1[i] <= Q5[i] && Q1[i] <= Q6[i]) &&
(Q4[i] >= Q1[i] && Q4[i] >= Q2[i] && Q4[i] >= Q3[i] && Q4[i] >= Q5[i] && Q4[i] >= Q6[i]))
return average1b;
else if ((Q1[i] <= Q2[i] && Q1[i] <= Q3[i] && Q1[i] <= Q4[i] && Q1[i] <= Q5[i] && Q1[i] <= Q6[i]) &&
(Q5[i] >= Q1[i] && Q5[i] >= Q2[i] && Q5[i] >= Q3[i] && Q5[i] >= Q4[i] && Q5[i] >= Q6[i]))
return average1c;
else if ((Q1[i] <= Q2[i] && Q1[i] <= Q3[i] && Q1[i] <= Q4[i] && Q1[i] <= Q5[i] && Q1[i] <= Q6[i]) &&
(Q6[i] >= Q1[i] && Q6[i] >= Q2[i] && Q6[i] >= Q3[i] && Q6[i] >= Q4[i] && Q6[i] >= Q5[i]))
return average1d;

else if ((Q2[i] <= Q1[i] && Q2[i] <= Q3[i] && Q2[i] <= Q4[i] && Q2[i] <= Q5[i] && Q2[i] <= Q6[i]) &&
(Q1[i] >= Q2[i] && Q1[i] >= Q3[i] && Q1[i] >= Q4[i] && Q1[i] >= Q5[i] && Q1[i] >= Q6[i]))
return average2;
else if ((Q2[i] <= Q1[i] && Q2[i] <= Q3[i] && Q2[i] <= Q4[i] && Q2[i] <= Q5[i] && Q2[i] <= Q6[i]) &&
(Q3[i] >= Q2[i] && Q3[i] >= Q1[i] && Q3[i] >= Q4[i] && Q3[i] >= Q5[i] && Q3[i] >= Q6[i]))
return average2a;
else if ((Q2[i] <= Q1[i] && Q2[i] <= Q3[i] && Q2[i] <= Q4[i] && Q2[i] <= Q5[i] && Q2[i] <= Q6[i]) &&
(Q4[i] >= Q1[i] && Q4[i] >= Q2[i] && Q4[i] >= Q3[i] && Q4[i] >= Q5[i] && Q4[i] >= Q6[i]))
return average2b;
else if ((Q2[i] <= Q1[i] && Q2[i] <= Q3[i] && Q2[i] <= Q4[i] && Q2[i] <= Q5[i] && Q2[i] <= Q6[i]) &&
(Q5[i] >= Q1[i] && Q5[i] >= Q2[i] && Q5[i] >= Q3[i] && Q5[i] >= Q4[i] && Q5[i] >= Q6[i]))
return average2c;
else if ((Q2[i] <= Q1[i] && Q2[i] <= Q3[i] && Q2[i] <= Q4[i] && Q2[i] <= Q5[i] && Q2[i] <= Q6[i]) &&
(Q6[i] >= Q1[i] && Q6[i] >= Q2[i] && Q6[i] >= Q3[i] && Q6[i] >= Q4[i] && Q6[i] >= Q5[i]))
return average2d;

else if ((Q3[i] <= Q1[i] && Q3[i] <= Q2[i] && Q3[i] <= Q4[i] && Q3[i] <= Q5[i])&&
(Q1[i] >= Q2[i] && Q1[i] >= Q3[i] && Q1[i] >= Q4[i] && Q1[i] >= Q5[i] && Q1[i] >= Q6[i]))
return average3;
else if ((Q3[i] <= Q1[i] && Q3[i] <= Q2[i] && Q3[i] <= Q4[i] && Q3[i] <= Q5[i])&&
(Q2[i] >= Q1[i] && Q2[i] >= Q3[i] && Q2[i] >= Q4[i] && Q2[i] >= Q5[i] && Q2[i] >= Q6[i]))
return average3a;
else if ((Q3[i] <= Q1[i] && Q3[i] <= Q2[i] && Q3[i] <= Q4[i] && Q3[i] <= Q5[i])&&
(Q4[i] >= Q1[i] && Q4[i] >= Q2[i] && Q4[i] >= Q3[i] && Q4[i] >= Q5[i] && Q4[i] >= Q6[i]))
return average3b;
else if ((Q3[i] <= Q1[i] && Q3[i] <= Q2[i] && Q3[i] <= Q4[i] && Q3[i] <= Q5[i])&&
(Q5[i] >= Q1[i] && Q5[i] >= Q2[i] && Q5[i] >= Q3[i] && Q5[i] >= Q4[i] && Q5[i] >= Q6[i]))
return average3c;
else if ((Q3[i] <= Q1[i] && Q3[i] <= Q2[i] && Q3[i] <= Q4[i] && Q3[i] <= Q5[i])&&
(Q6[i] >= Q1[i] && Q6[i] >= Q2[i] && Q6[i] >= Q3[i] && Q6[i] >= Q4[i] && Q6[i] >= Q5[i]))
return average3d;

else if ((Q4[i] <= Q1[i] && Q4[i] <= Q2[i] && Q4[i] <= Q3[i] && Q4[i] <= Q5[i] && Q4[i] <= Q6[i])&&
(Q1[i] >= Q2[i] && Q1[i] >= Q3[i] && Q1[i] >= Q4[i] && Q1[i] >= Q5[i] && Q1[i] >= Q6[i]))
return average4;
else if ((Q4[i] <= Q1[i] && Q4[i] <= Q2[i] && Q4[i] <= Q3[i] && Q4[i] <= Q5[i] && Q4[i] <= Q6[i])&&
(Q2[i] >= Q1[i] && Q2[i] >= Q3[i] && Q2[i] >= Q4[i] && Q2[i] >= Q5[i] && Q2[i] >= Q6[i]))
return average4a;
else if ((Q4[i] <= Q1[i] && Q4[i] <= Q2[i] && Q4[i] <= Q3[i] && Q4[i] <= Q5[i] && Q4[i] <= Q6[i])&&
(Q3[i] >= Q2[i] && Q3[i] >= Q1[i] && Q3[i] >= Q4[i] && Q3[i] >= Q5[i] && Q3[i] >= Q6[i]))
return average4b;
else if ((Q4[i] <= Q1[i] && Q4[i] <= Q2[i] && Q4[i] <= Q3[i] && Q4[i] <= Q5[i] && Q4[i] <= Q6[i])&&
(Q5[i] >= Q1[i] && Q5[i] >= Q2[i] && Q5[i] >= Q3[i] && Q5[i] >= Q4[i] && Q5[i] >= Q6[i]))
return average4c;
else if ((Q4[i] <= Q1[i] && Q4[i] <= Q2[i] && Q4[i] <= Q3[i] && Q4[i] <= Q5[i] && Q4[i] <= Q6[i])&&
(Q6[i] >= Q1[i] && Q6[i] >= Q2[i] && Q6[i] >= Q3[i] && Q6[i] >= Q4[i] && Q6[i] >= Q5[i]))
return average4d;

else if ((Q5[i] <= Q1[i] && Q5[i] <= Q2[i] && Q5[i] <= Q3[i] && Q5[i] <= Q4[i] && Q5[i] <= Q6[i])&&
(Q1[i] >= Q2[i] && Q1[i] >= Q3[i] && Q1[i] >= Q4[i] && Q1[i] >= Q5[i] && Q1[i] >= Q6[i]))
return average5;
else if ((Q5[i] <= Q1[i] && Q5[i] <= Q2[i] && Q5[i] <= Q3[i] && Q5[i] <= Q4[i] && Q5[i] <= Q6[i])&&
(Q2[i] >= Q1[i] && Q2[i] >= Q3[i] && Q2[i] >= Q4[i] && Q2[i] >= Q5[i] && Q2[i] >= Q6[i]))
return average5a;
else if ((Q5[i] <= Q1[i] && Q5[i] <= Q2[i] && Q5[i] <= Q3[i] && Q5[i] <= Q4[i] && Q5[i] <= Q6[i])&&
(Q3[i] >= Q2[i] && Q3[i] >= Q1[i] && Q3[i] >= Q4[i] && Q3[i] >= Q5[i] && Q3[i] >= Q6[i]))
return average5b;
else if ((Q5[i] <= Q1[i] && Q5[i] <= Q2[i] && Q5[i] <= Q3[i] && Q5[i] <= Q4[i] && Q5[i] <= Q6[i])&&
(Q4[i] >= Q1[i] && Q4[i] >= Q2[i] && Q4[i] >= Q3[i] && Q4[i] >= Q5[i] && Q4[i] >= Q6[i]))
return average5c;
else if ((Q5[i] <= Q1[i] && Q5[i] <= Q2[i] && Q5[i] <= Q3[i] && Q5[i] <= Q4[i] && Q5[i] <= Q6[i])&&
(Q6[i] >= Q1[i] && Q6[i] >= Q2[i] && Q6[i] >= Q3[i] && Q6[i] >= Q4[i] && Q6[i] >= Q5[i]))
return average5d;

else if ((Q6[i] <= Q1[i] && Q6[i] <= Q2[i] && Q6[i] <= Q3[i] && Q6[i] <= Q4[i] && Q6[i] <= Q5[i])&&
(Q1[i] >= Q2[i] && Q1[i] >= Q3[i] && Q1[i] >= Q4[i] && Q1[i] >= Q5[i] && Q1[i] >= Q6[i]))
return average6;
else if ((Q6[i] <= Q1[i] && Q6[i] <= Q2[i] && Q6[i] <= Q3[i] && Q6[i] <= Q4[i] && Q6[i] <= Q5[i])&&
(Q2[i] >= Q1[i] && Q2[i] >= Q3[i] && Q2[i] >= Q4[i] && Q2[i] >= Q5[i] && Q2[i] >= Q6[i]))
return average6a;
else if ((Q6[i] <= Q1[i] && Q6[i] <= Q2[i] && Q6[i] <= Q3[i] && Q6[i] <= Q4[i] && Q6[i] <= Q5[i])&&
(Q3[i] >= Q2[i] && Q3[i] >= Q1[i] && Q3[i] >= Q4[i] && Q3[i] >= Q5[i] && Q3[i] >= Q6[i]))
return average6b;
else if ((Q6[i] <= Q1[i] && Q6[i] <= Q2[i] && Q6[i] <= Q3[i] && Q6[i] <= Q4[i] && Q6[i] <= Q5[i])&&
(Q4[i] >= Q1[i] && Q4[i] >= Q2[i] && Q4[i] >= Q3[i] && Q4[i] >= Q5[i] && Q4[i] >= Q6[i]))
return average6c;
else if ((Q6[i] <= Q1[i] && Q6[i] <= Q2[i] && Q6[i] <= Q3[i] && Q6[i] <= Q4[i] && Q6[i] <= Q5[i])&&
(Q5[i] >= Q1[i] && Q5[i] >= Q2[i] && Q5[i] >= Q3[i] && Q5[i] >= Q4[i] && Q5[i] >= Q6[i]))
return average6d;

if (Q1[i] > Q2[i] && Q1[i] > Q3[i] && Q1[i] > Q4[i] && Q1[i] > Q5[i] && Q1[i] > Q6[i])
return largest1;
else if (Q2[i] > Q1[i] && Q2[i] > Q3[i] && Q2[i] > Q4[i] && Q2[i] > Q5[i] && Q2[i] > Q6[i])
return largest2;
else if (Q3[i] > Q2[i] && Q3[i] > Q1[i] && Q3[i] > Q4[i] && Q3[i] > Q5[i] && Q3[i] > Q6[i])
return largest3;
else if (Q4[i] > Q1[i] && Q4[i] > Q2[i] && Q4[i] > Q3[i] && Q4[i] > Q5[i] && Q4[i] > Q6[i])
return largest4;
else if (Q5[i] > Q1[i] && Q5[i] > Q2[i] && Q5[i] > Q3[i] && Q5[i] > Q4[i] && Q5[i] > Q6[i])
return largest5;
else if (Q6[i] > Q1[i] && Q6[i] > Q2[i] && Q6[i] > Q3[i] && Q6[i] > Q4[i] && Q6[i] > Q5[i])
return largest6;
else
return 0;
}``````

You can't really use a switch statement based on averages. Its better to use a series of if statements so that you can gest ranges of values

``````if( average > 90)
return 'A';
else if( average > 80 )
return 'B';
// etc etc``````

You can't really use a switch statement based on averages. Its better to use a series of if statements so that you can gest ranges of values

``````if( average > 90)
return 'A';
else if( average > 80 )
return 'B';
// etc etc``````

How can I import them using the average1, average1a, average1b...etc from the previous function until I can clean it up?

would it be like this

``char calcGrade(double average1&, double average1a&....)``

pop in a variable to get that value for use in the subsequent function call

``````double avgstore;
..... Q6[i] << setw(8) << Final[i] << (avgstore = CalculateAvg (students, id, fname, lname, Q1, Q2, Q3, MidTerm, Q4, Q5, Q6, Final, i));
cout <<calcGrade(avgstore);   (try it tacked onto the end of the first cout just in case, I wasn't sure if it would be evaluated in the right order)``````

same for out <<

pop in a variable to get that value for use in the subsequent function call

``````double avgstore;
..... Q6[i] << setw(8) << Final[i] << (avgstore = CalculateAvg (students, id, fname, lname, Q1, Q2, Q3, MidTerm, Q4, Q5, Q6, Final, i));
cout <<calcGrade(avgstore);   (try it tacked onto the end of the first cout just in case, I wasn't sure if it would be evaluated in the right order)``````

same for out <<

Are you saying that the avgstore is found in the main program? So, I would decalre is as: double avgstore; , and then my function would be like this:

``````double calcGrade(double avgstore)
{
if (avgstore > 90)
cout << 'A';
else if (avgstore > 80)
cout << 'A'

etc....
}``````

You can call it whatever you want in the function, but yes I meant back in main keep an intermediate variable of your average function output and then feed that back into your grade function. I was just saying don't put them all on the same line because I'm not 100% sure if the grade function will be called before the other comes back with the value.

You can call it whatever you want in the function, but yes I meant back in main keep an intermediate variable of your average function output and then feed that back into your grade function. I was just saying don't put them all on the same line because I'm not 100% sure if the grade function will be called before the other comes back with the value.

And I'm guessing that I messed up when saying "cout << 'A' " since the double function has to return a value...right?

Yes, and your function should return a char. Sry was trying to make sure you got things in the right place in main()

Yes, and your function should return a char. Sry was trying to make sure you got things in the right place in main()

Yes, all the stuff in the main works just as you said...thanks! I'm not sure how return a char in my double function....would I be better served turning the function into a "char calcGrade(avgstore)"?

yes and putting `return 'A';` etc. within your statements

``````if (avgstore > 90)
return 'A';
else if (avgstore >80)
return 'B';
...
else
return 'F';``````

yes and putting `return 'A';` etc. within your statements

``````if (avgstore > 90)
return 'A';
else if (avgstore >80)
return 'B';
...
else
return 'F';``````

Ok....I got that working, but now it won't allow me to have some space between the numerical avg values, and the char grade. This is my output:

``````Enter name of file
students

StudentID    LastName    FirstName   Q1     Q2     Q3     Mid    Q4      Q5     Q6     Final    Avg.    Grade
--------------------------------------------------------------------------------------------
45256        Rodrigues   Joana       58     75     58     61     59      75     63      92      66.9D
37915        Wright      Michelle    98     83     56     62     63      90     57      67      67.8D
81984        Williams    Jenny       55     67     54     63     89      84     93      75      69.3D
73984        Phaneuf     Lesley      78     85     57     51     68      94     51      83      68.4D
80886        Laflamme    Nicole      76     51     71     94     69      78     87      91      77.4C
39473        Kenyon      Patricia    65     54     90     68     94      70     95      97      78.0C
Press any key to continue . . .``````

and this is the code:

``````cout << left << setw(13) << studentid[i] << setw(12) << fname[i] << setw(12) << lname[i] << setw(7)
<< Q1[i] << setw(7) << Q2[i] << setw(7) << Q3[i] << setw(7) << MidTerm[i] << setw(8)
<< Q4[i] << setw(7) << Q5[i] << setw(8) << Q6[i] << setw(8) << Final[i] <<
(avgstore = CalculateAvg (students, id, fname, lname, Q1, Q2, Q3, MidTerm, Q4, Q5, Q6, Final, i)) <<