/********************************************
This program reads in grades from grades.txt,
which has 10 homework grades for 10 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*[10];
  for(int i = 0; i < 10; i++)
    grade[i] = new int[10];

  // Read in grade data
  ifstream IN("grades.txt");
  for(int s = 0; s < 10; s++)
    for(int g = 0; g < 10; 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;
}