Program needs to be in C++ The program will have a person, student, and faculty class. Use an STL for a list rather than using the "list" class. Populate an STL structure with a series of objects (at least 5 combined). Create a list of POINTERS to objects, so you can use polymorphism. The beginning of the list should be all faculty (add to the head), and the end of the list (add at the tail) should be students/interns. It is not necessary to add the base class objects. Utilize the STL functions to apply: add student/intern/faculty, remove a specific entry from a user input of a name, search for name, print all, and delete all. The menu items will be in main and call the STL functions. Please use the code below and make the appropriate edits #include #include using namespace std; struct Date {     int month, year; }; class Person { protected:     string name, department; public:     Person() {         name = "";         department = "";     }     Person(string n, string d) {         name = n, department = d;     }     void print() {         cout << "Name: " << name << endl;         cout << "Department: " << department << endl;     }     string getName() {         return name;     }     string getDepartment() {         return department;     }     ~Person() {         cout << "\nDone";     } }; class Student : public Person { protected:     Date graduationDate; public:     Student() {         graduationDate.month = 0;         graduationDate.year = 0;     }     Student(string n, string d, Date date) {         name = n, department = d;         graduationDate = date;     }     void setGraduationDate(Date d) {         graduationDate = d;     }     Date getGraduationDate() {         return graduationDate;     }     int timeToGraduation(Date today) {         if (today.month > graduationDate.month) {             return ((graduationDate.year - today.year - 1) * 12 +                 (12 - today.month) + graduationDate.month);         }         else {             return ((graduationDate.year - today.year) * 12 +                 abs(today.month - graduationDate.month));         }     }     void print() {         cout << "Name: " << name << endl;         cout << "Department: " << department << endl;         cout << "Graduation Date: " << graduationDate.month << "/" << graduationDate.year << endl;     } }; class Faculty : public Person { protected:     Date startDate;     string title; public:     Faculty(string n, string d, string t, Date date) {         name = n, department = d, title = t;         startDate = date;     }     void setTitle(string t) {         title = t;     }     void setStartDate(Date d) {         startDate = d;     }     string getTitle() {         return title;     }     Date getStartDate() {         return startDate;     }     void print() {         cout << "Name: " << name << endl;         cout << "Department: " << department << endl;         cout << "Title: " << title << endl;         cout << "Start Date: " << startDate.month << "/" << startDate.year << endl;     } }; class Intern : public Student { protected:     string company;     double salary; public:     Intern(string n, string d, Date date, string c, double s) {         name = n, department = d;         graduationDate = date;         company = c;         salary = s;     }     void setSalary(double s) {         salary = s;     }     void setCompany(string c) {         company = c;     }     string getCompany() {         return company;     }     double getSalary() {         return salary;     }     void print() {         cout << "Name: " << name << endl;         cout << "Department: " << department << endl;         cout << "Company: " << company << endl;         cout << "Salary: " << salary << endl;         cout << "Graduation Date: " << graduationDate.month << "/" << graduationDate.year << endl;     } }; int main() {     Date today, graduation;     today.month = 3;     today.year = 2021;     graduation.month = 10;     graduation.year = 2027;     Student John("John Smith", "Computer Science", graduation);     Faculty Chris("Chris Smith", "Computer Science", "Associate Professor", today);     Intern Bob("Bob Smith", "Computer Science", graduation, "Apple", 60000.0);     Student* studentArray = new Student[10];     John.print();     cout << "Time for John to graduate: " << John.timeToGraduation(today) << " months\n";     cout << endl;     Chris.print();     cout << endl;     Bob.print();     cout << "Time for Bob to graduate: " << Bob.timeToGraduation(today) << " months\n";     return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

Program needs to be in C++

The program will have a person, student, and faculty class. Use an STL for a list rather than using the "list" class. Populate an STL structure with a series of objects (at least 5 combined). Create a list of POINTERS to objects, so you can use polymorphism. The beginning of the list should be all faculty (add to the head), and the end of the list (add at the tail) should be students/interns. It is not necessary to add the base class objects. Utilize the STL functions to apply: add student/intern/faculty, remove a specific entry from a user input of a name, search for name, print all, and delete all. The menu items will be in main and call the STL functions.

Please use the code below and make the appropriate edits

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

struct Date {
    int month, year;
};

class Person {
protected:
    string name, department;
public:
    Person() {
        name = "";
        department = "";
    }
    Person(string n, string d) {
        name = n, department = d;
    }
    void print() {
        cout << "Name: " << name << endl;
        cout << "Department: " << department << endl;
    }
    string getName() {
        return name;
    }
    string getDepartment() {
        return department;
    }
    ~Person() {
        cout << "\nDone";
    }
};

class Student : public Person {
protected:
    Date graduationDate;
public:
    Student() {
        graduationDate.month = 0;
        graduationDate.year = 0;
    }
    Student(string n, string d, Date date) {
        name = n, department = d;
        graduationDate = date;
    }
    void setGraduationDate(Date d) {
        graduationDate = d;
    }
    Date getGraduationDate() {
        return graduationDate;
    }
    int timeToGraduation(Date today) {
        if (today.month > graduationDate.month) {
            return ((graduationDate.year - today.year - 1) * 12 +
                (12 - today.month) + graduationDate.month);
        }
        else {
            return ((graduationDate.year - today.year) * 12 +
                abs(today.month - graduationDate.month));
        }
    }
    void print() {
        cout << "Name: " << name << endl;
        cout << "Department: " << department << endl;
        cout << "Graduation Date: " << graduationDate.month << "/" << graduationDate.year << endl;
    }
};

class Faculty : public Person {
protected:
    Date startDate;
    string title;
public:
    Faculty(string n, string d, string t, Date date) {
        name = n, department = d, title = t;
        startDate = date;
    }
    void setTitle(string t) {
        title = t;
    }
    void setStartDate(Date d) {
        startDate = d;
    }
    string getTitle() {
        return title;
    }
    Date getStartDate() {
        return startDate;
    }
    void print() {
        cout << "Name: " << name << endl;
        cout << "Department: " << department << endl;
        cout << "Title: " << title << endl;
        cout << "Start Date: " << startDate.month << "/" << startDate.year << endl;
    }
};

class Intern : public Student {
protected:
    string company;
    double salary;
public:
    Intern(string n, string d, Date date, string c, double s) {
        name = n, department = d;
        graduationDate = date;
        company = c;
        salary = s;
    }
    void setSalary(double s) {
        salary = s;
    }
    void setCompany(string c) {
        company = c;
    }
    string getCompany() {
        return company;
    }
    double getSalary() {
        return salary;
    }
    void print() {
        cout << "Name: " << name << endl;
        cout << "Department: " << department << endl;
        cout << "Company: " << company << endl;
        cout << "Salary: " << salary << endl;
        cout << "Graduation Date: " << graduationDate.month << "/" << graduationDate.year << endl;
    }
};

int main() {
    Date today, graduation;
    today.month = 3;
    today.year = 2021;
    graduation.month = 10;
    graduation.year = 2027;

    Student John("John Smith", "Computer Science", graduation);
    Faculty Chris("Chris Smith", "Computer Science", "Associate Professor", today);
    Intern Bob("Bob Smith", "Computer Science", graduation, "Apple", 60000.0);

    Student* studentArray = new Student[10];

    John.print();
    cout << "Time for John to graduate: " << John.timeToGraduation(today) << " months\n";
    cout << endl;
    Chris.print();
    cout << endl;
    Bob.print();
    cout << "Time for Bob to graduate: " << Bob.timeToGraduation(today) << " months\n";
    return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education