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

I really need help writing this C++ progam. I have seen many answers to this que

ID: 3833193 • Letter: I

Question

I really need help writing this C++ progam. I have seen many answers to this question on this site, but they are all deeply flawed.

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

ream>
#include <cstdlib>
#include <cstdio>
#include <conio>
#include <iomanip>
#include <string>
#include <new>
using namespace std;

void printMenu();

class person
{
   protected:
       string fName, lName, address, zip, phone;
   public:
      
       person(string firstname="", string lastname="", string add="", string zipcode="", string phonenum=""){
          
       };
      
       void setFirstName(){
           cout<<"Enter first name: ";
           cin >> this->fName;
           cout<<endl;
       }
      
       void setLastName(){
           cout<<"Enter last name: ";
           cin >> this->lName;
           cout<<endl;
       }
      
       void setAddress(){
           cout<<"Enter address: ";
           cin >> this->address;
           cout<<endl;
       }
      
       void setZip(){
           cout<<"Enter zip Code: ";
           cin >> this->zip;
           cout<<endl;
       }
      
       void setPhone(){
           cout<<"Enter phone number: ";
           cin >> this->phone;
           cout<<endl;
       }
      
       void setData(){
          
           setFirstName();
           setLastName();
           setAddress();
           setZip();
           setPhone();  
          
       }
      
       void Display(){
           cout<<"First Name: "<<this->fName<<endl;
           cout<<"Last Name: "<<this->lName<<endl;
           cout<<"Address: "<<this->address<<endl;
           cout<<"Zip code: "<<this->zip<<endl;
           cout<<"Phone number:"<<this->phone<<endl<<endl;
       }
      
};

class collegeEmployee: public person
{
   private:
       string SSnumber, salary, deptName;
   public:
      
       collegeEmployee(string firstname="", string lastname="", string add="", string zipcode="", string phonenum="", string SS="", string anualSal="", string department="")
       :person(firstname, lastname,add,zipcode,phonenum)
       {
      
          
       };
      
       void setSSnumber(){
          
           cout<<"Enter Social Security Number: ";
           cin>>this->SSnumber;  
           cout<<endl;
          
       }
      
       void setSalary(){
           cout<<"Enter Annual Salary: ";
           cin>>this->salary;  
           cout<<endl;
       }
      
       void setDeptName(){
           cout<<"Enter Department Name: ";
           cin>>this->deptName;  
           cout<<endl;
       }
      
       void setData(){
          
           setFirstName();
           setLastName();
           setAddress();
           setZip();
           setPhone();  
           setSSnumber();
           setSalary();
           setDeptName();
          
       }
      
       void Display(){
          
           cout<<"First Name: "<<this->fName<<endl;
           cout<<"Last Name: "<<this->lName<<endl;
           cout<<"Address: "<<this->address<<endl;
           cout<<"Zip code: "<<this->zip<<endl;
           cout<<"Phone number:"<<this->phone<<endl<<endl;
           cout<<"Social Security Number: "<<this->SSnumber<<endl;
           cout<<"Salary: "<<this->salary<<endl;
           cout<<"Department Name: "<<this->deptName<<endl;
          
       }
      
};

class student: public person
{
   protected:
       string major, fieldOfStudy, gpa;
   public:
       student(string firstname="", string lastname="", string add="", string zipcode="", string phonenum="", string maj="", string study="", string GPA="")
       :person(firstname, lastname,add,zipcode,phonenum)
       {
      
          
       };
      
       void setMajor(){
          
           cout<<"Enter Major: ";
           cin>>this->major;  
           cout<<endl;
       }
      
      
       void setStudy(){
           cout<<"Enter Field of Study: ";
           cin>>this->fieldOfStudy;  
           cout<<endl;
       }
      
       void setGpa(){
           cout<<"Enter GPA: ";
           cin>>this->gpa;  
           cout<<endl;
       }
      
       void setData(){
          
           setFirstName();
           setLastName();
           setAddress();
           setZip();
           setPhone();  
           setMajor();
           setStudy();
           setGpa();
          
       }
      
       void Display(){
          
           cout<<"First Name: "<<this->fName<<endl;
           cout<<"Last Name: "<<this->lName<<endl;
           cout<<"Address: "<<this->address<<endl;
           cout<<"Zip code: "<<this->zip<<endl;
           cout<<"Phone number:"<<this->phone<<endl;
           cout<<"Major: "<<this->major<<endl;
           cout<<"Field of Study: "<<this->fieldOfStudy<<endl;
           cout<<"GPA: "<<this->gpa<<endl;
       }
};

class faculty: public collegeEmployee
{
   protected:
       bool isTenured;
   public:
       faculty(string firstname="", string lastname="", string add="", string zipcode="", string phonenum="", string SS="", string anualSal="", string department="")
       :collegeEmployee(firstname, lastname, add, zipcode, phonenum, SS, anualSal, department)
       {
          
          
      
   };
  
      bool setTenure()
       {
           char answer;
           cout<<"Is this faculty member tenured? (Y/N): ";
           cin>>answer;
          
           if (answer=='Y'||answer=='y') this->isTenured = true;
           else this->isTenured = false;
          
           cout<<endl;
       }
      
       void setData(){
          
           setFirstName();
           setLastName();
           setAddress();
           setZip();
           setPhone();  
           setSSnumber();
           setSalary();
           setDeptName();
           setTenure();
       }
      
       void Display(){
          
           cout<<"First Name: "<<this->fName<<endl;
           cout<<"Last Name: "<<this->lName<<endl;
           cout<<"Address: "<<this->address<<endl;
           cout<<"Zip code: "<<this->zip<<endl;
           cout<<"Phone number:"<<this->phone<<endl;
           cout<<"Tenure: "<<this->isTenured<<endl;
          
       }
};

struct CollegeList {

   collegeEmployee emp[4];
   faculty fac[3];
   student stud[7];
};

int main() {

struct CollegeList mylist
collegeEmployee emp[4];
faculty fac[3];
student stud[7];

///// Menu
char choice;  
int empCounter=0;
int facCounter=0;
int studCounter=0;  
while(true){

printf(" Please enter : ");
cout<<"C = CollegeEmployee"<<endl;
cout<<"F = for Faculty"<<endl;
cout<<"S = for Student"<<endl;
cout<<"Q = Quit"<<endl;

cout<<"Note: Entered data should be Case sensitive "<<endl;

choice.getchar();
cout<<endl;


switch(choice){
  
   case 'C': {
   if(empCounter>=4) {
   cout<<"Too many College Employees"<<endl;
   break;
   }
   mylist.emp[empCounter].setData();
   empCounter++;
   break;
   }
  
   case 'F': {
   if(facCounter>=3) {
   cout<<"Too many College Faculty"<<endl;
   break;
   }
   mylist.fac[facCounter].setData();
   facCounter++;
   break;
   }
  
   case 'S': {
   if(studCounter>=7) {
   cout<<"Too many College Students"<<endl;
   break;
   }
   mylist.stud[studCounter].setData();
   facCounter++;
   break;
   }  
   case 'Q':{
  
if(empCounter==0) cout<<"No College Employees to display"<<endl;
if(facCounter==0) cout<<"No Faculty to display"<<endl;
if(studCounter==0) cout<<"No Students Employees to display"<<endl;
  
   for(int i=0;i<empCounter;i++){
       cout<<"College Employees////////// "<<endl;
       mylist.emp[i].Display();
       cout<<endl<<endl;
   }
   for(int i=0;i<facCounter;i++){
       cout<<"Faculty//////////////"<<endl;
       mylist.fac[i].Display();
       cout<<endl<<endl;
   }
   for(int i=0;i<studCounter;i++){
       cout<<"Studnets///////////"<<endl;
       mylist.stud[i].Display();
       cout<<endl<<endl;
   }
  
  
           exit(1);
}
   default: cout<<"Please enter a correct choice. "<<endl<<endl;
}

}


system("pause");
return 0;

}