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

Create a C++ program that will prompt the user, through a menu, to enter data on

ID: 3833499 • Letter: C

Question

Create a C++ program that will prompt the user, through a menu, to enter data on various employees within an organization and display their pay. Use the information as specified below.

1. Create a class according to the following specifications:

            Class Name:     emp

            Data:                EmpName - pointer to a character

                                    EmpSSN - long integer

            Methods:         

                        1. A default constructor to initialize the data members.

                        2. A copy constructor

                        2. A destructor.

                        4. Accessor functions for both data members.

                        5. A function named display() to display both data members on one line with no labels.

2. Derive the following classes from the above:

            Class Name:     hourly_emp

            Data:                EmpRate - float, representing the hourly rate of pay

                                    EmpHours - an integer representing the number of hours worked.

            Methods:         

                        1. A default constructor, a copy constructor, and a destructor.

                        2. Accessor functions for the data members of this class.

                        3. A function named display() to display the name, SSN, and the amount of pay

                                    (rate * hours) for an hourly employee.

            Class Name:     salaried_emp

            Data:                EmpSalary - float, representing the salary

            Methods:         

                        1. A default constructor, a copy constructor, and a destructor.

                        2. An accessor function for the data member of this class.

                        3. A function named display()   to display the name, SSN, and the amount of pay for a  salaried employee.

  

After you have defined the above classes, write a main() function (to include any necessary subfunctions required to create a structured, modularized program !!!) to test your classes. This function should:

1. Display a menu to prompt the user to enter an integer value to identify the employee class:

                              1 = Salaried

                              2 = Hourly

                              3 = Unclassified

2. Accept input and create an instance of the appropriate class. (For your convenience you may create three pointer arrays for the three data types. For test purposes, assume no more that 5 employees of each type.)

3.   Repeat Steps 1 and 2 until the user indicates there are no more inputs.

4.   Display, grouped by employee classification, all of the information produced by the output functions of the class.

Be sure your test program is user friendly and all displays are well formatted and readable.

Explanation / Answer

//Program for Menu driven Employee Operation

#include <iostream>

using namespace std;
class Emp{
    public:
        char *empname[];
        long empSSN;
        Emp(){
            empname=&ename;
            ename={'A','m','i','t'};
            empSSN=1211;
        }
        Emp(char *en,long eSSN){
            en=empname;
            eSSN=empSSN;
        }
        ~Emp(){
            cout<<" Destructor called ";
        }
        void display(){
            cout<<" The Employee name is:"<<*empname;
            cout<<" The Employee SSN is:"<<empSSN;
        }

}
class Hourly_Emp extends Emp{
    public:
        float emprate;
        int emphrs;
        Hourly_Emp(){
            emprate=1.30;
            emphrs=8;
        }
        Hourly_Emp(float er,int eh){
            er=emprate;
            eh=emphrs;
        }
        ~Hourly_Emp(){
            cout<<" Destructor called ";
        }
        void display(){
            cout<<" The Employee name is:"<<*empname;
            cout<<" The Employee SSN is:"<<empSSN;
            cout<<" The Employee rate of payment is:"<<emprate*emphrs;
            cout<<" The Employee total working hours is:"<<emphrs;
        }
}
class Salaried_Emp extends Hourly_Emp{
    public:
        float empsal;
        Salaried_Emp(){
            empsal="2500";
        }
        Salaried_Emp(float emps){
            emps=empsal;
        }
        Salaried_Emp(){
            cout<<" Destructor called ";
        }
        void display(){
            cout<<" The Employee name is:"<<*empname;
            cout<<" The Employee SSN is:"<<empSSN;
            cout<<" The Employee salary is:"<<empsal;
        }
       
}
int main()
{
    int ch;    
    char op;
   cout << "Enter a category code specific for a empployee:" << endl;
   cin>>ch;
   cout<<" 1. Salaried Employee";
   cout<<" 2. Hourly Employee";
   cout<<" 3. Unclassified Employee";
   Emp e;
   Hourly_Emp he;
   Salaried_Emp se;
   do{
        switch(ch){
       case 1: cout<<"1.---Salaried Employee---";
               cout<<" The Employee name is:"<<e.*empname;
               cout<<" The Employee SSN is:"<<e.empSSN;
               cout<<" The Employee salary is:"<<se.empsal;
               break;
       case 2: cout<<"2.---Hourly Employee";
               cout<<" The Employee name is:"<<e.*empname;
               cout<<" The Employee SSN is:"<<e.empSSN;
               cout<<" The Employee rate of payment is:"<<he.emprate*he.emphrs;
               cout<<" The Employee total working hours is:"<<he.emphrs;
               break;
       case 3: cout<<"3.Unclassified";
               cout<<" The Employee name is:"<<e.*empname;
               cout<<" The Employee SSN is:"<<e.empSSN;
               break;
        default:cout<<" Invalid Choice!!!";      
   }while(op=='n' && op=='N');
  
return 0;
}