title: Student Grading Program C++
body: <p>I am writing a simple program in C++ that reads an sample input like below from a text file:
      Sample Input</p>
  
  <pre><code>    7 10
      William Horde AA AA AA AA AA AA AA AA AA AA ;
      John Doe AA AA AA FF AA AA AA AA AA AA ;
      Hermann Straus AA AA AA AA AA BB NA AA AA AA ;
      Patrick Doe CC CC DC CC CB CC DC CC CC CC ;
      Xhulia Abazi AA BB BB BA CB BB CB CC BB AA;
      John Trki CC BB DC DD DD DD BB AA BB CC ;
      Julien Torfelt NA FD FD DD DC DC DC DD DD ;
  </code></pre>
  
  <p>In the first line are given the number of student 0
  
  <p>Below is my source code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ofstream&gt;
  
  using namespace std;
  void getData(char fnames[], char lnames[], string grades[], int &amp;n, int &amp;m);
  
  int main()
  {
      char fnames[100]; 
      char lnames[100]; 
      string grades[100]; int n,m;
  
      getData(fnames,lnames, grades , n, m);
      return 0;
  }
  
  
  void getData(char fnames[],char lnames[], string grades[], int &amp;n, int &amp;m)
  {
      ifstream fin("input.txt");
      fin&gt;&gt;n; // read number of students
      fin&gt;&gt;m; // read number of courses
      double sum = 0.0;
      for (int i=0; i&lt;n; i++)
      {
          fin&gt;&gt;fnames;
          fin&gt;&gt;lnames;
  
          for (int j=0; j&lt;m; j++)
          {
              fin&gt;&gt;grades[j];
              if(grades[j]=="AA") sum = sum + 4.0;
              else if(grades[j]=="BA") sum = sum + 3.5;
              else if(grades[j]=="BB") sum = sum + 3.0;
              else if(grades[j]=="CB") sum = sum + 2.5;
              else if(grades[j]=="CC") sum = sum + 2.0;
              else if(grades[j]=="DC") sum = sum + 1.5;
              else if(grades[j]=="DD") sum = sum + 1.0;
              else if(grades[j]=="FD") sum = sum + 0.5;
              else sum = sum + 0.0; //FF , NA    
          }
      }        
  }
  </code></pre>
  
  <p>How can I make my program to works correctly ?</p>