### Assigning values to letters in a 2D character array

Hello,

what I have here is a program that reads letters (grades) from a 2D character array and out puts them into a row/column system that shows the grades of 3 subjects for 5 different students.

My next objective is to calculate and display the GPA of each student by adding the 3 grades per student and then dividing it by 3.

This requires that I assign a value to each grade from the array into the format of A = 4, B = 3, C = 2, D = 1, F = 0. But I am having trouble with figuring out how to do this.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172`` ``````// grades.txt A A B C C F C D B B A C B A B // main.cpp #include #include using namespace std; int main() { char grades[5][3]; int ROW; int COL; // opens grades.txt ifstream inFile; inFile.open("grades.txt"); if (inFile.fail()) { cout << "Error! File did not open!... now closing...\n\n"; exit(1); } cout << "All Grades\n" << "Student" << '\t' << "English" << '\t' << "History" << '\t' << "Math" << '\t' << '\n'; // reads grades.txt into 2D array for (int ROW = 0; ROW < 5; ROW++) { for (int COL = 0; COL < 3; COL++) { inFile >> grades[ROW][COL]; } } // outputs characters in 2D array for (int ROW = 0; ROW < 5; ROW++) { cout << "#" << ROW+1 << '\t'; for (int COL = 0; COL < 3; COL++) { cout << grades[ROW][COL] << '\t'; } cout << endl; } cout << endl; inFile.close(); return 0; }``````
 ``123456789`` `````` // reads grades.txt into 2D array for (int ROW = 0; ROW < 5; ROW++) { for (int COL = 0; COL < 3; COL++) { inFile >> grades[ROW][COL]; grades[ROW][COL] = 4+'A'-grades[ROW][COL];//'A'-grades[ROW][COL] == (0 to -4) + 4 == (4 to 0) } }``````