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

Design the following classes in C++. Person class is the base class for other cl

ID: 3835344 • Letter: D

Question

Design the following classes in C++. Person class is the base class for other classes. Person – A Person contains a first name, last name, street address, zip code, and phone number. The class also includes a method that sets each data field, using a series of output/input commands and a display method that displays all of a Person’s information on a multiple lines at the command line on the screen. CollegeEmployee – A CollegeEmployee descends from Person. A CollegeEmployee also includes a Social Security number, an annual salary, and a department name, as well as methods that override the Person methods to accept and display all CollegeEmployee data. Faculty – Faculty descends from CollegeEmployee. This class also includes a Boolean field that indicates whether the Faculty member is tenured, as well as methods that override the CollegeEmployee methods to accept and display this additional piece of information. Student – Student descends from Person. In addition to the fields available in Person, a Student contains a major field of study and a grade point average, as well as methods that override the Person methods to accept and display these additional facts. Write an application named CollegeList that declares an array of four “regular” CollegeEmployees, three Faculty, and seven Students. Prompt the user – using a menu to specify which type of person’s data will be entered (‘C’, ‘F’, or ‘S’), or allow the user to quit (‘Q’). While the user chooses to continue (that is, does not quit), accept data entry for the appropriate type of Person. If the user attempts to enter data for more than four CollegeEmployees, three Faculty, or seven Students, display an error message. When the user quits, display a report on the screen listing each group of Persons under the appropriate heading “College Employees,” “Faculty,” or “Students.” If the user has not entered data for one or more types of Persons during a session, display an appropriate message under the appropriate heading.

Explanation / Answer

#include<iostream.h>
#include<string>

class Person {
private:
    string firstname;
    string lastname;
    string streetAddress;
    string zipcode;
    string phone_number;
public:
     void setValues( string name1, string name2, string addr, string zip, string phone){
          firstname = name1;
          lastname = name2;
          streetAddress = adr;
          zipcode = zip;
          phone_number = phone;
     }
     void getValues(){
          cout << firstname << endl;
          cout << lastname << endl;
          cout << streetAddress << endl;
          cout << zipcode << endl;
          cout << phone_number << endl
     }

};

class CollegeEmployee : public Person {
   private:
        string ssn;
        string sal;
        string dept;
   public:
     void setValues( string name1, string name2, string addr, string zip, string phone,
                      string ssn1, string sal1, string dept1){
          Person::setPersonValues( string name1, string name2, string addr, string zip, string phone);
          ssn = ssn1;
          sal = sal1;
          dept = dept1;
     }
     void getValues(){
          Person::getValues();
          cout << ssn << endl;
          cout << sal << endl;
          cout << dept << endl;
     }
   
};

class Faculty : public CollegeEmployee {
      private:
         bool tenured;
      public:
         void setValues( string name1, string name2, string addr, string zip, string phone,
                      string ssn1, string sal1, string dept1, string ten){
              CollegeEmployee::setValues( string name1, string name2, string addr, string zip, string phone,
                      string ssn1, string sal1, string dept1);
              if (ten == "true")
                 tenured = true;
              if (ten == "false")
                 tenured = false;
         }
         void getValues(){
             CollegeEmployees::getValues();
             cout << tenured << endl;
         }
};

class Student : public Person {
      private:
         string major;
         string gpa;
      public:
         void setValues( string name1, string name2, string addr, string zip, string phone, string maj, string gpa1){
              Person::setValues(string name1, string name2, string addr, string zip, string phone);
              major = maj;
              gpa = gpa1;
         }
         void getValues(){
             Person::getValues();
             cout << major << endl;
             cout << gpa << endl;
         }
};

void main(){
     CollegeEmployee CEmp[4];
     Faculty fac[3];
     Student stu[7];
     int ccount, fcount, scount;
     string firstname, lastname, addr, zip, phno, ssn, sal, dept, major, gpa, tenured;
     char ch;
     
     ccount = 0;
     fcount = 0;
     scount = 0;

     do {
         cout << "C) Enter data for CollegeEmployee" << endl;
         cout << "F) Enter data for CollegeEmployee" << endl;
         cout << "S) Enter data for CollegeEmployee" << endl;
         cout << "Q) Quit" << endl;
         cin >> ch
         if (ch != 'Q'){
            switch (ch) {
                 case 'C':
                     if (ccount < 4){
                         cout << Enter CollegeEmployee Data: firstname, lastname, adder, zip, phno, social
                              social security no, salary, dept";
                         cin >> firstname >> lastname >> addr >> zip >> phno >> ssn >> sal >> dept;
                         CEmp[ccount].setValues(firstname ,lastname , addr , zip , phno , ssn , sal, dept);
                         ccount++;
                      }
                      else {
                           cout << "Already 4 CollegeEmployee Data has been entered" << endl;
                      }
                 case 'F':
                     if (fcount < 3){
                         cout << Enter Faculty Data: firstname, lastname, adder, zip, phno, social
                              social security no, salary, dept, tenured(true/false)";
                         cin >> firstname >> lastname >> addr >> zip >> phno >> ssn >> sal >> dept >> tenured;
                         fac[fcount].setValues(firstname ,lastname , addr , zip , phno , ssn , sal, dept,tenured);
                         fcount++;
                      }
                      else {
                           cout << "Already 3 Faculty Data has been entered" << endl;
                      }
                 case 'S':
                     if (scount < 3){
                         cout << Enter Student Data: firstname, lastname, adder, zip, phno, major,
                              gpa";
                         cin >> firstname >> lastname >> addr >> zip >> phno >> ssn >> sal >> dept;
                         stu[scount].setValues(firstname ,lastname , addr , zip , phno , ssn , sal, dept);
                         scount++;
                      }
                      else {
                           cout << "Already 7 Student Data has been entered" << endl;
                      }

            }
         }    
    }while (ch != 'Q')
    cout << "College Employee Data" << endl;
    if (ccount > 0){
       for (int i = 0; i<ccount; i++){
           CEmp[i].getValues();
           cout << "------------------------------" << endl;
       }
    }
    else {
       cout << "No data for College Employee";
    }
    cout << "Faculty Data" << endl;
    if (fcount > 0){
       for (int i = 0; i<fcount; i++){
           fac[i].getValues();
           cout << "------------------------------" << endl;
       }
    }
    else {
       cout << "No data for faculty";
    }
    cout << "Student Data" << endl;
    if (scount > 0){
       for (int i = 0; i<scount; i++){
           stu[i].getValues();
           cout << "------------------------------" << endl;
       }
    }
    else {
       cout << "No data for Students";
    }
        
}

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