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

PLEASE DO BOTH PARTS! PLEASE DO NOT write it out I have a hard time reading peop

ID: 3856838 • Letter: P

Question

PLEASE DO BOTH PARTS! PLEASE DO NOT write it out I have a hard time reading people's hand writing please just type it out. Thanks for any and all help I appreciate it!

Part A: Write a c++ program that prompts the user to enter information about course enrollments, and writes this data to file coursedata.txt, located in the folder Test on drive C:. Use CSIT courses currently being offered, but include only those taught by one of the following professors: Buzi, Hu, Maloney, Scialdone, Zubairi. For each course, enter the subject code and number, the instructor's last name, and the enrollment - for example:

CSIT 201
Zubairi
30

CSIT 221
Buzi
16

CSIT 241
Maloney
24

...

CSIT 463
Buzi
22

Note that the data should be written to the file in increasing order by course number.

Part B: Write a program that reads the data from the file produced in Part A, and produces a report showing the courses taught by each instructor, along with their enrollments, and the total enrollment for that instructor. This report should be written to the file coursereport.txt, located in the folder Test on drive C:. It should be in order by instructor last name - for example:

Buzi
CSIT 221 16
CSIT 341 25
CSIT 463 22
Total: 63

...

Zubairi
CSIT 201 30
CSIT 251 23
CSIT 425 15
Total: 68

Explanation / Answer

Make a structure, to hold three values.Make a file stream and open a file in write mode. I Have made array of structure of size 10 just to testing purpose, you can make it high. Put a while loop to continue asking user to insert data

At the end of each loop, use the inbuilt sort function, to sort based on the course name. Here is the code.

#include <fstream>

#include <iostream>

using namespace std;

struct CourseData

{

char cname[50];

char name[50];

int enroll;

};

int main () {

  

int flag=1;

   // open a file in write mode.

   ofstream outfile;

   outfile.open("coursedata.txt");

   CourseData *array = new CourseData[10];

   while(flag)

   {

   CourseData c1;

   cout << "CourseData" << endl;

   cout << "Enter your Course Name: ";

   cin.get(c1.cname,50);

   outfile <<c1.cname << endl;

   cout << "Enter your name of Prof.: ";

   cin.get(c1.name,50);

   outfile << c1.name << endl;

   cout << "Enter Enrollment: ";

   cin >> c1.enroll;

   cin.ignore();

   // again write inputted data into the file.

   outfile << c1.enroll << endl;

   cout<<"Add more?(1 or 0)";

   cin>>flag;

   std::sort(array, array+10, [](CourseData const &a,CourseData const &b){ return a.cname < b.cname; });

   }

   // close the opened file.

   outfile.close();

   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