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

Could you complete the incomplete code below without adding any header file? Ple

ID: 3592093 • Letter: C

Question

Could you complete the incomplete code below without adding any header file?

Please use the given header file only.

--------------------------------------------------------------------

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

struct Student {

   string firstName;

   string lastName;

   int id;

};

class Course {

   private:

       string name;

       int crn;

       int section;

       Student students[100];

       int numStudents;

      

   public:

       Course() {

          

       }

      

       Course(string n, int c, int s) {

           name = n;

           crn = c;

           section = s;

           numStudents = 0;

       }

      

       void modifyInfo(string n, int c, int s) {

           name = n;

           crn = c;

           section = s;

           numStudents = 0;

       }

      

       int getCrn() {

           return crn;

       }

      

       void addStudent(Student stu) {

           students[numStudents].firstName = stu.firstName;

           students[numStudents].lastName = stu.lastName;

           students[numStudents].id = stu.id;

           numStudents++;

       }

};

void load(Course schedule[100], int& numCourses);

void print(Course schedule[100], int numCourses);

int main() {

   // init vars

   Course schedule[100];

   int numCourses = 0;

   char sc = 'a';

  

   // menu loop

   while(sc != 'e') {

       // prompt and get menu choice

       cout << endl << endl << endl

       << "Would you like to load, print, add a student, add a course, or exit (l/p/s/c/e): ";

       cin >> sc;

      

       // choose function based on user input

       switch(sc) {

           case 'e':

               cout << "Thanks for using the roster program!";

               break;

           case 'l':

               load(schedule, numCourses);

               break;

           case 'p':

               print(schedule);

               break;

              

           case 'c':

               string name;

               int crn, section;

               cout << "Please enter the course name, crn and section: ";

               cin >> name >> crn >> section;

               schedule[numCourses].modifyInfo(name, crn, section);

               numCourses++;

               break;

              

           case 's':

               // get the crn of the course

               cout << "Please enter the crn of the course you'd like to add a student to: ";

               int crn;

               cin >> crn;

              

               // find which course in the array that corresponds to that crn

              

               // create the student and add the student that course

               break;

              

           default:

               cout << "That was not a valid option, please try again!";

       }

   }

  

   return 0;

}

// this function gets the file path from the user

// then opens the file, reads it with a loop,

// and saves the data read from the file into the array

void load(Course schedule[100], int numCourses) {

   // does course exist already?

  

   // if so, add student to it

  

   // if not, create the course and add the student

}

// this function prints the contents of the array

// prettily using the setw function (#include <iomanip>)

void print(Course schedule[100], int numCourses) {

  

}

Explanation / Answer

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

struct Student {

   string firstName;

   string lastName;

   int id;

};

class Course {

   private:

       string name;

       int crn;

       int section;

       Student students[100];

       int numStudents;

      

   public:

       Course() {

          

       }

      

       Course(string n, int c, int s) {

           name = n;

           crn = c;

           section = s;

           numStudents = 0;

       }

      

       void modifyInfo(string n, int c, int s) {

           name = n;

           crn = c;

           section = s;

           numStudents = 0;

       }

      

       int getCrn() {

           return crn;

       }

      

       void addStudent(Student stu) {

           students[numStudents].firstName = stu.firstName;

           students[numStudents].lastName = stu.lastName;

           students[numStudents].id = stu.id;

           numStudents++;

       }

};

void load(Course schedule[100], int& numCourses);

void print(Course schedule[100], int numCourses);

int main() {

   // init vars

   Course schedule[100];

   int numCourses = 0;

   char sc = 'a';

  

   // menu loop

   while(sc != 'e') {

       // prompt and get menu choice

       cout << endl << endl << endl

       << "Would you like to load, print, add a student, add a course, or exit (l/p/s/c/e): ";

       cin >> sc;

      

       // choose function based on user input

       switch(sc) {

           case 'e':

               cout << "Thanks for using the roster program!";

               break;

           case 'l':

               load(schedule, numCourses);

               break;

           case 'p':

               print(schedule);

               break;

              

           case 'c':

               string name;

               int crn, section;

               cout << "Please enter the course name, crn and section: ";

               cin >> name >> crn >> section;

               schedule[numCourses].modifyInfo(name, crn, section);

               numCourses++;

               break;

              

           case 's':

               // get the crn of the course

               cout << "Please enter the crn of the course you'd like to add a student to: ";

               int crn;

               cin >> crn;

              

               // find which course in the array that corresponds to that crn

              

               // create the student and add the student that course

               break;

              

           default:

               cout << "That was not a valid option, please try again!";

       }

   }

  

   return 0;

}

// this function gets the file path from the user

// then opens the file, reads it with a loop,

// and saves the data read from the file into the array

void load(Course schedule[100], int numCourses) {

   // does course exist already?

  

   // if so, add student to it

  

   // if not, create the course and add the student

}

// this function prints the contents of the array

// prettily using the setw function (#include <iomanip>)

void print(Course schedule[100], int numCourses) {

  

}

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