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

Please help!!!!! Where there are // is where code needs to be written please hel

ID: 3817647 • Letter: P

Question

Please help!!!!! Where there are // is where code needs to be written please help!!!!!! Don't ask for better pictures this is the best they will get just enlarge them and you should be able to read them. Thanks for any and all help!!!!




(15 points) folder Data on the c: drive. The file coursedata .txt, in the semester, The data looks contains information on course enrollments for a certain CSIT 104 cs IT 104 csir 473 Nazarenko 00 Each record contains the information for one The data is organized into records. subject code and course section. course section, and includes, on separate lines: (1) the for that the ins last name: (4) the with a "dummy 2) the section number, and the file ends Important: The records are ordered by course file the nonexistent course, CsiT 999. n Write a program to read the file and produce a report, showing the number of sections and total enrollment for each This report should Here is a sample the c: be rollment data, located in the Data folder what this report might look like: catT 104 CSIT 105 CSIT 473

Explanation / Answer

#include <fstream>
#include <string>
using namespace std;

int main()
{
    //Declare the files.
    ifstream input;
    ofstream output;

    //Open the input file.
    input.open("C:/Data/coursedata.txt", std::ios::in);

    //Open the output file.
    output.open("C:/Data/enrollmentdata.txt");

    //Declare the variables.
    int count1; //number of sections of a course.
    int total; //total enrollment for a course.
    string current; //current subj code and no.
    string next; //next subj code and no.
    string temp;
    int n;

    //Read data for the first section.
    input>>next;

    while(!(next.find("999"))){
        //Continue until the end of the input file.
        current = next;
        count1 = 0;
        total = 0;
        while(next == current)
        {
            //Update count and total.
            input>>temp;
            count1 += 1;
            input>>temp;
            input>>n;
            total += n;

            //Read data for the next section.
            input>>next;
        }
        //Write the information for the current
        //course to the output file.
        output<<current;
        output<<count1;
        output<<total;
    }
    //Write the information for the last course
    //to the output file.
    output<<next;
    input>>temp;
    output<<temp;
    input>>temp;
    input>>temp;
    output<<temp;

    output.close();
    input.close();
    return 0;
}