Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++ program that includes the following: // Course.h #ifndef COURSE_H #define COURSE_H #include #include using namespace std; struct NodeType { string student_name; NodeType*
Write a C++ program that includes the following:
// Course.h #ifndef COURSE_H #define COURSE_H #include#include using namespace std; struct NodeType { string student_name; NodeType* next; }; class Course { public: // Default constructor Course(); // Creates a course with the specified name. Course(const string& course_name); // Destructor ~Course(); // Returns the course name. string get_course_name() const; // Adds a new student to the course. void add_student(const string& new_student); // Drops the specified student void drop_student(const string& drop_student); // Returns the pointer of students for the course. NodeType* get_students() const; // Prints the course name and the added students. void print_course() const; private: // The name of the course string course_name; //A collection of students who take the course. students is a pointer which points to a linked structure. NodeType* students; }; #endif
- Define the class Student in the header file Course.h.
- Implement the class Course in the file Course.cpp.
- The main function is contained in the file lab02.cpp. The main function,
- Prompts the user to enter the course name and creates a course.
- Prompts the user to enter the student name and add the student in the course, stop adding the students when the user enter "exit" as student name
- Prompts the user to enter the student name to be removed, and remove the student from the course.
- Displays the course name and students added in the course.
The expected result:
Enter the course name: CSE330 The course is created. Add the students in the course Enter the student name: Taylor The student is added Enter the student name: Jim The student is added Enter the student name: Alice The student is added Enter the student name: exit Enter the student that will be removed: Jim The student is removed The course information: CSE330 Taylor Alice
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started