/********************************************
This program reads in grades from grades.txt,
which has 6 homework grades for 5 students.
The user then can query the program to
determine specific student/hw grades.
********************************************/
#include <fstream>
using namespace std;
int main()
{
// Create array for grades
int** grade= new int*[5];
for(int i= 0; i< 5; i++)
grade[i] = new int[6];
// Read in grade data
ifstream IN("grades.txt");
for(int s = 0; s< 5; s++)
for(int g = 0; g < 6; g++)
IN >> grade[s][g];
// Allow user to get grade info
char c;
do {
// Get query & return result
int sn, hw;
cout << "Student number [0..9]: ";
cin >> sn;
cout << "Homework number [0..9]: ";
cin >> hw;
cout << "Grade was " << grade[sn][hw] << endl;
// Figure out whether we quit
cout << "(Q)uit or (V)iew record? ";
cin >> c;
}while(c != 'Q');
return 0;
}