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 c

ID: 665370 • 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. (25 points)

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. (25 points)

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. (25 points)

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. (25 points)

write the c++ code and show output

Explanation / Answer

Code To Copy:

//Remove the following line

//if not using visual studio.

#include "stdafx.h"

//Include the

//required header files.

#include <iostream>

#include <string>

//Use the standard namespace.

using namespace std;

//Create the class Person.

class Person

{

//Declare the data members.

string fname;

string lname;

int zip;

string phone_no;

//Define the public

//member functions.

public:

Person()

{

   

}

void set_val()

{

    cout << "Enter the first name: ";

    cin >> fname;

    cout << "Enter the last name: ";

    cin >> lname;

    cout << "Enter the zip code: ";

    cin >> zip;

    cout << "Enter the phone no: ";

    cin >> phone_no;

}

void disp()

{

    cout << "First name: "

    << fname<<endl;

    cout << "Last name: "

    << lname<<endl;

    cout << "Zip code: "

    << zip<<endl;

    cout << "Phone no: "

    << phone_no<<endl;

}

};

//Create the class CollegeEmployee.

class CollegeEmployee : public Person

{

//Declate the data members.

string SSN;

float salary;

string dept_name;

//Define the public member functions.

public:

CollegeEmployee()

{

   

}

void set_val ()

{

    Person::set_val();

    cout << "Enter the SSN: ";

    cin >> SSN;

    cout << "Enter the salary: ";

    cin >> salary;

    cout << "Enter the department name: ";

    cin >> dept_name;

   

}

void disp()

{

    Person::disp();

    cout << "Salary: "

    << salary<<endl;

    cout << "SSN: "

    << SSN<<endl;

    cout << "Department name: "

    << dept_name<<endl;

   

}

};

//Create the class Faculty.

class Faculty : public CollegeEmployee

{

//Declare the data members.

bool is_tenured;

//Define the public

//member functions.

public:

Faculty()

{

   

}

void set_val ()

{

    CollegeEmployee::set_val();

    char ch;

    cout << "Is the Faculty tenured? (y/n)";

    cin>>ch;

    if(ch == 'y')

    {

      is_tenured = true;

    }

    else

    {

      is_tenured = false;

    }

   

}

void disp()

{

    CollegeEmployee::disp();

    if(is_tenured)

    {

    cout << "Tenured"<<endl;

    }

    else

    {

      cout << "Not tenured"<<endl;

    }

}

};

//Create the class Student.

class Student : public Person

{

//Declare the data members.

string major;

char grade;

//Define the public

//member functions.

public:

Student()

{

   

}

void set_val()

{

    Person::set_val();

    cout << "Enter the major: ";

    cin >> major;

    cout << "Enter the grade: ";

    cin >> grade;

}

void disp()

{

    Person::disp();

    cout <<"Major: "

    <<major<<endl;

    cout << "Grade: "

    << grade<<endl;

}

};

//Define the main() function.

int main()

{

//Define the required objects.

CollegeEmployee col[4];

Faculty fac[3];

Student stu[7];

//Declare the required variables.

int no_col=0;

int no_fac= 0;

int no_stu = 0;

char ch;

//Run the loop to store

//the data as per user choice.

do

{

    //Display the menu.

    cout << "1.CollegeEmployee (C) 2.Faculty(F) 3.Student(S) 4.Quit(Q) ";

    cout << "Enter the choice: (C,F,S,Q): ";

    cin >> ch;

   

    //Move to the appropriate

    //case block as per the user choice.

    switch(ch)

    {

   

      case 'C':

     

      //If CollegeEmployees are less than 4.

      if(no_col < 4)

      {

        col[no_col++].set_val();

      }

      else

      {

        cout << "No more data for"

        <<" CollegeEmployees can be entered.";

      }

      break;

     

      case 'F':

     

      //If the faculty

      //members are less than 3.

      if(no_fac < 3)

      {

        fac[no_fac++].set_val();

      }

     

      //Else case.

      else

      {

        cout << "No more data for"

        <<" faculties can be entered.";

      }

      break;

     

     

      case 'S':

     

      //If students are less than 7.

      if(no_stu < 7)

      {

        stu[no_stu++].set_val();

      }

     

      //Else case.

      else

      {

        cout << "No more data for"

        <<" Students can be entered.";

      }

      break;

     

     

      case 'Q':

     

      //Display the data of all the created objects.

      if(no_col==0)

      {

        cout<<"No data available for CollegeEmployees. ";

      }

      else

      {

        for(int i=0;i<no_col;i++)

        {

          col[i].disp();

        }

      }

    

      if (no_fac==0)

      {

        cout << "No data available for faculties. ";

      }

     

      else

      {

        for(int i=0;i<no_fac;i++)

        {

          fac[i].disp();

        }

      }

     

      if (no_stu==0)

      {

        cout << "No data available for Students. ";

      }

     

      else

      {

        for(int i=0;i<no_stu;i++)

        {

          stu[i].disp();

        }

      }

     

      break;

     

      //If the user enters a wrong choice.

      default:

      cout << "You entered a wrong choice ";

    }

}

//Run the loop till the user wants to quit.

while(ch!='Q');

//Remove the following line

//if not using visual studio.

system ("pause");

return 0;

}

Sample Output:

1.CollegeEmployee (C)

2.Faculty(F)

3.Student(S)

4.Quit(Q)

Enter the choice: (C,F,S,Q): F

Enter the first name: Fac1

Enter the last name: Teach1

Enter the zip code: 12121

Enter the phone no: 3231-1212

Enter the SSN: 1233212

Enter the salary: 3242.22

Enter the department name: CS

Is the Faculty tenured? (y/n) y

1.CollegeEmployee (C)

2.Faculty(F)

3.Student(S)

4.Quit(Q)

Enter the choice: (C,F,S,Q): C

Enter the first name: Emp1

Enter the last name: last1

Enter the zip code: 3312

Enter the phone no: 45112-121

Enter the SSN: 23441122

Enter the salary: 23451.20

Enter the department name: Dance

1.CollegeEmployee (C)

2.Faculty(F)

3.Student(S)

4.Quit(Q)

Enter the choice: (C,F,S,Q): S

Enter the first name: Stud1

Enter the last name: L1

Enter the zip code: 221212

Enter the phone no: 56721212-121212

Enter the major: Drumming

Enter the grade: A

1.CollegeEmployee (C)

2.Faculty(F)

3.Student(S)

4.Quit(Q)

Enter the choice: (C,F,S,Q): Q

First name: Emp1

Last name: last1

Zip code: 3312

Phone no: 45112-121

Salary: 23451.2

SSN: 23441122

Department name: Dance

First name: Fac1

Last name: Teach1

Zip code: 12121

Phone no: 3231-1212

Salary: 3242.22

SSN: 1233212

Department name: CS

Tenured

First name: Stud1

Last name: L1

Zip code: 221212

Phone no: 56721212-121212

Major: Drumming

Grade: A

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