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

In C++ Write a program that prints out a student grade report. There is a file,

ID: 3839445 • Letter: I

Question

In C++

Write a program that prints out a student grade report. There is a file, classes.txt, that contains the names of all classes taught at a college, such as classes.txt 1 CSC1 2 CSC2 3 CSC46 4 CSC151 5 MTH121 6 ... For each class, there is a file with student numbers and grades: csc2.txt

1 11234 A-

2 12547 B

3 16753 B+

4 21886 C

5 ...

Write a program that asks for a student ID and prints out a grade report for that student, by searching all class files.

Here is a sample report

Student ID 16753

CSC2 B+

MTH121 C+

CHN1 A

PHY50 A

Explanation / Answer

#include<iostream.h>
#include<string>
#include<locale>

using namespace std;

void main(){

   std::locale loc;
   vector<string> courselist;
   ifstream infile;
   string a1, a2, a3;
   string id;
   infile.open("classes.txt:);
   while (infile >> a1 >> a2){
       vector.push_back(a2);
   }

   cout << "Enter student id" << endl;
   cin >> id;
   cout << "Student ID" << "   " << id
   for (int i = 0; i<courselist.size(); i++){
       infile.open(std::tolower(courselist.at(i),loc) + ".txt");
       while (infile >> a1 >> a2 >> a3){
             if (a2 == id){
                cout << courselist.at(i) << " " << a3;
             }
       }
   }
  
}