Alright guys so I have some homework due tomorrow and I am having trouble with my output function, I could do it this way but its going to be ridiculously long. I have to read from an input file and get a list of students and grades and have 3 arrays and 3 functions, one for reading the information from the file, one for calculation, and one for outputting the information to console.

file:

Johnson 85 83 77 91 76

Aniston 80 90 95 93 48

Cooper 78 81 11 90 73

Gupta 92 83 30 69 87

Blair 23 45 96 38 59

Clark 60 85 45 39 67

Kennedy 77 31 52 74 83

Bronson 93 94 89 77 97

Sunny 79 85 28 93 82

Smith 85 72 49 75 63

--------------------------------

so this is my code so far, I am asking for help with an easier way to do my output function.

please help guys, i dont have allot of time.Code:#include <fstream> #include <iostream> #include <string> #include <iomanip> #include <cstdlib> // for system("pause") using namespace std; void read(int& x, int&y); void calculate(); void output(); string students[10]; double scores[10][5]; double averages[10]; double cave; double studentaveofx0; double studentaveofx1; double studentaveofx2; double studentaveofx3; double studentaveofx4; double studentaveofx5; double studentaveofx6; double studentaveofx7; double studentaveofx8; double studentaveofx9; int main () { int x; int y; read(x, y); calculate(); output(); system("pause"); return 0; } void read(int& x, int&y) { ifstream inData; inData.open("students.txt"); cout << setprecision(2); cout << fixed; for (x = 0; x < 10; x++) { inData >> students[x]; cout << students[x] << " "; for(y = 0;y < 5;y++) { inData >> scores[x][y]; cout << scores[x][y] << " "; } cout << endl; } inData.close(); cout << "**********************************" << endl; } void calculate() { int x; int y; double result; for (x = 0; x < 10; x++) { for(y = 0;y < 5;y++) { averages[x] += scores[x][y]; } } // ummmm...... this is crazy... must be an easier way studentaveofx0 = averages[0]/y; studentaveofx1 = averages[1]/y; studentaveofx2 = averages[2]/y; studentaveofx3 = averages[3]/y; studentaveofx4 = averages[4]/y; studentaveofx5 = averages[5]/y; studentaveofx6 = averages[6]/y; studentaveofx7 = averages[7]/y; studentaveofx8 = averages[8]/y; studentaveofx9 = averages[9]/y; for (x = 0; x < 10;x++) { result += (averages[x] / 5); } cave = result/x; } void output(){ if(studentaveofx0 >= 90 && studentaveofx0 <= 100){ cout << students[0] << ": A" << endl; } else if(studentaveofx0 >= 80 && studentaveofx0 < 90){ cout << students[0] << ": B" << endl; } else if(studentaveofx0 >= 70 && studentaveofx0 < 80){ cout << students[0] << ": C" << endl; } else if(studentaveofx0 >= 60 && studentaveofx0 < 70){ cout << students[0] << ": D" << endl; } else{ cout << students[0] << ": F" << endl; } if(studentaveofx1 >= 90 && studentaveofx1 <= 100){ cout << students[1] << ": A" << endl; } else if(studentaveofx1 >= 80 && studentaveofx1 < 90){ cout << students[1] << ": B" << endl; } else if(studentaveofx1 >= 70 && studentaveofx1 < 80){ cout << students[1] << ": C" << endl; } else if(studentaveofx1 >= 60 && studentaveofx1 < 70){ cout << students[1] << ": D" << endl; } else{ cout << students[1] << ": F" << endl; } if(studentaveofx2 >= 90 && studentaveofx2 <= 100){ cout << students[2] << ": A" << endl; } else if(studentaveofx2 >= 80 && studentaveofx2 < 90){ cout << students[2] << ": B" << endl; } else if(studentaveofx2 >= 70 && studentaveofx2 < 80){ cout << students[2] << ": C" << endl; } else if(studentaveofx2 >= 60 && studentaveofx2 < 70){ cout << students[2] << ": D" << endl; } else{ cout << students[2] << ": F" << endl; } // how to just increment a variable for printing purposes? cout << "**********************************" << endl; cout << "Class Average: " << cave << endl; cout << "**********************************" << endl; }

output so far, didnt finish it all... but it outputs correctly so far.