Question: Could you complete the incomplete code below without adding any header file? -------------------------------------------------------------------- #include #include #include using namespace std; struct Student { string firstName; string

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

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

#include

#include

#include

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 )

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

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!