Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help help creating a raptor file that will read a file of student letter

ID: 646518 • Letter: I

Question

I need help help creating a raptor file that will read a file of student letter grades and corresponding grade points and load them into two paired arrays, as follows: Letter grade Grade points A 12 B 9 C 6 D 3 F 0 my program is to read each record on the file (which contains a letter grade followed by a grade point), validate the letter grade (which must be A,B,C,D,OF F), check that the grade point is numeric, and load the values into the parallel arrays. My program is to stop processing when the files reaches EOF or the arrays are full. Print an error message if there are more records on the file than elements in the array.

Explanation / Answer

#include <iostream>
#include <fstream>

using namespace std;

int main(){
   const int max = 100;
   char grade[100];
   int points[100];
   char g;
   int count = 0, p;
   string fName;
   cout << "Enter file Name: ";
   cin >> fName;
   ifstream in;
   in.open(fName.c_str());
   if(in.is_open()){
       while(in >> g){
           if(count == max){
               cout << "Error: There are more recorde on file than elements in array" << endl;
               return 0;
           }
           if(g != 'A' && g != 'B' && g != 'C' && g != 'D' && g != 'F'){
               cout << "Error: Invalid grade" << endl;
               return 0;
           }
           else{
               grade[count] = g;
           }
           if(in >> p){
               points[count++] = p;
           }
           else{
               cout << "Error: grade point must be numeric" << endl;
               return 0;
           }
       }
       for(int i = 0; i < count; ++i){
           cout << grade[i] << " " << points[i] << endl;
       }
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote