Question

Design a class named Employee. The class should keep the following information in

WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.

1. Employee and ProductionWorker Classes

Design a class named Employee. The class should keep the following information in

• Employee name

• Employee number

• Hire date

Write one or more constructors and the appropriate accessor and mutator functions for the class.

Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:

• Shift (an integer)

• Hourly pay rate (a double )

The workday is divided into two shifts: day and night. The shift variable will hold an integer value representing the shift that the employee works. The day shift is shift 1, and the night shift is shift 2. Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the classes by writing a program that uses a ProductionWorker object.

2. ShiftSupervisor Class

In a particular factory a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Design a ShiftSupervisor class that is derived from the Employee class you created in Programming Challenge 1. The ShiftSupervisor class should have a member variable that holds the annual salary and a member variable that holds the annual production bonus that a shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the class by writing a program that uses a ShiftSupervisor object.

3. TeamLeader Class

In a particular factory, a team leader is an hourly paid production worker who leads a small team. In addition to hourly pay, team leaders earn a fixed monthly bonus. Team leaders are required to attend a minimum number of hours of training per year. Design a TeamLeader class that extends the ProductionWorker class you designed in Programming Challenge 1. The TeamLeader class should have member variables for the monthly bonus amount, the required number of training hours, and the number of training hours that the team leader has attended. Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the class by writing a program that uses a TeamLeader object.

3 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

1)

//Header file section

#include< iostream >

#include< string >

using namespace std;

//defining class Employee

class Employee

{

private:string EmpName;

        int EmpNumber;

        string Hiredate;

        //Default constructor

public:   Employee()

          {

              EmpName=" ";

              EmpNumber=0;

              Hiredate=" ";

          }

          //Parameterized constructor

          Employee(string name,int number,string date)

          {

              EmpName=name;

              EmpNumber=number;

              Hiredate=date;

          }

      //Member functions

        void setEmpName(string);

        void setEmpNumber(int);

        void setHireDate(string);

        string getEmpName();

        int getEmpNumber();

        string getHireDate();

};

//Defining member functions

void Employee::setEmpName(string str)

{

     EmpName=str;

}//end setEmpName

void Employee::setEmpNumber(int num)

{

     EmpNumber=num;

}//end setEmpNumber

void Employee::setHireDate(string date)

{

      Hiredate=date;

}//end setHireDate

string Employee::getEmpName()

{

     return EmpName;

}//end getEmpName

int Employee::getEmpNumber()

{

     return EmpNumber;

}//end getEmpNumber

string Employee::getHireDate()

{

     return Hiredate;

}//end getHireDate

//defining derived class ProductionWorker

class ProductionWorker:public Employee

{

private:int Shift;

          double HourlyPay;

             //Default constructor

public: ProductionWorker()

          {

              Shift=0;

              HourlyPay=0;

          }

          //Parameterized constructor

          ProductionWorker(int sh,double pay)

          {

              Shift=sh;

              HourlyPay=pay;

          }

          void setShift(int);

          void setHourlyPay(double);

          int getShift();

          double getHourlyPay();

};

//Defining member functions

void ProductionWorker::setShift(int sh)

{

     Shift=sh;

}//end setShift

void ProductionWorker::setHourlyPay(double pay)

{

    HourlyPay=pay;

}//end setHourlyPay

int ProductionWorker::getShift()

{

     return Shift;

}//end getShift

double ProductionWorker::getHourlyPay()

{

     return HourlyPay;

}//end getHourlyPay

//Main function

int main()

{//Start main

     int shift;

     double pay;

     //Inputting data

     cout<<" 1-DayShift \n 2-Night"<

     cout<<"Enter shift:";

     cin>>shift;

     cout<<"Enter hourly pay:";

     cin>>pay;

     //creating ProductionWorker object

     ProductionWorker emp1(shift,pay);

     //setting the values to employee class using

     //emp1 object

     emp1.setEmpName("Winston");

     emp1.setEmpNumber(562);

     emp1.setHireDate(" June:11");

     //outputting data using accessor functions

     cout<<"Employee Details:"<

     cout<<"Employee Name:"<

     cout<<"Employee Number:"<

     cout<<"Employee Hire Date:"<

     cout<<"Employee Shift:"<

     cout<<"EmployeeHourlyPay:"<

     //Pause system for a while

     system("pause");

     return 0;

}

//end main

   2)

#include< iostream >

#include< string >

using namespace std;

//defining class Employee

class Employee

{

protected:string EmpName;

         int EmpNumber;

         string Hiredate;

        //Default constructor

public:   Employee()

          {

              EmpName=" ";

              EmpNumber=0;

              Hiredate=" ";

          }

          //Parameterized constructor

          Employee(string name,int number,string date)

          {

              EmpName=name;

              EmpNumber=number;

              Hiredate=date;

          }

      //Member functions

public: void setEmpName(string);

        void setEmpNumber(int);

        void setHireDate(string);

        string getEmpName();

        int getEmpNumber();

        string getHireDate();

};

//Defining member functions

void Employee::setEmpName(string str)

{

     EmpName=str;

}//end setEmpName

void Employee::setEmpNumber(int num)

{

     EmpNumber=num;

}//end setEmpNumber

void Employee::setHireDate(string date)

{

      Hiredate=date;

}//end setHireDate

string Employee::getEmpName()

{

     return EmpName;

}//end getEmpName

int Employee::getEmpNumber()

{

     return EmpNumber;

}//end getEmpNumber

string Employee::getHireDate()

{

     return Hiredate;

}//end getHireDate

class ShiftSupervisor: public Employee

{

private: double AnnualSalary;

          double AnnualBonus;

public: //Default constructor

        ShiftSupervisor()

        {

             AnnualSalary=0.0;

             AnnualBonus=0.0;

        }

        //parameterized constructor

       ShiftSupervisor(double sal, double bonus)

        {

           AnnualSalary=sal;

           AnnualBonus=bonus;

        }

        //Declaring member functions

public:void setAnnualSalary(double);

        void setAnnualBonus(double);

        double getAnnualSalary();

        double getAnnualBonus();

};

void ShiftSupervisor::setAnnualBonus(double bonus)

{

     AnnualBonus=bonus;

}//end setAnnualBonus

void ShiftSupervisor::setAnnualSalary(double sal)

{

   AnnualSalary=sal;

}//end setAnnualSalary

double ShiftSupervisor::getAnnualBonus()

{

     return AnnualBonus;

}//end getAnnualBonus

double ShiftSupervisor::getAnnualSalary()

{

    return AnnualSalary;

}//end getAnnualSalary

//Main function

void main()

{

//start main

     //object to class ShiftSupervisor

   ShiftSupervisor emp1;

   //variable declaration

   string name;

   string date;

   double Abonus,Asalary;

   //Set data values to class object

   cout<<"Enter Employee Name:";

   cin>>name;

   emp1.setEmpName(name);

   emp1.setEmpNumber(562);

   emp1.setHireDate("June 21");

   cout<<"Enter Anual Bonus:";

   cin>>Abonus;

   emp1.setAnnualBonus(Abonus);

   cout<<"Enter Anual Salary:";

   cin>>Asalary;

   emp1.setAnnualSalary(Asalary);

   //Outputting data by calling Accessor functions

   cout<<"----Shift Supervisor Details---"<

   cout<<"Employee Name:"<

   cout<<"Employee Number:"<

   cout<<"Employee Hir Date:"<

   cout<<"Employee Annual salary:"<

   cout<<"Employee Annual Bonus :"<

   system("pause");

}//end main

3)

//Header file section

#include< iostream >

#include< string >

using namespace std;

//defining class Employee

class Employee

{

private:string EmpName;

        int EmpNumber;

        string Hiredate;

        //Default constructor

public:   Employee()

          {

              EmpName=" ";

              EmpNumber=0;

              Hiredate=" ";

          }

          //Parameterized constructor

          Employee(string name,int number,string date)

          {

              EmpName=name;

              EmpNumber=number;

              Hiredate=date;

          }

      //Member functions

        void setEmpName(string);

        void setEmpNumber(int);

        void setHireDate(string);

        string getEmpName();

        int getEmpNumber();

        string getHireDate();

};

//Defining member functions

void Employee::setEmpName(string str)

{

     EmpName=str;

}//end setEmpName

void Employee::setEmpNumber(int num)

{

     EmpNumber=num;

}//end setEmpNumber

void Employee::setHireDate(string date)

{

      Hiredate=date;

}//end setHireDate

string Employee::getEmpName()

{

     return EmpName;

}//end getEmpName

int Employee::getEmpNumber()

{

     return EmpNumber;

}//end getEmpNumber

string Employee::getHireDate()

{

     return Hiredate;

}//end getHireDate

//defining derived class ProductionWorker

class ProductionWorker:public Employee

{

private:int Shift;

          double HourlyPay;

             //Default constructor

public: ProductionWorker()

          {

              Shift=0;

              HourlyPay=0;

          }

          //Parameterized constructor

          ProductionWorker(int sh,double pay)

          {

              Shift=sh;

              HourlyPay=pay;

          }

          void setShift(int);

          void setHourlyPay(double);

          int getShift();

          double getHourlyPay();

};

//Defining member functions

void ProductionWorker::setShift(int sh)

{

     Shift=sh;

}//end setShift

void ProductionWorker::setHourlyPay(double pay)

{

    HourlyPay=pay;

}//end setHourlyPay

int ProductionWorker::getShift()

{

     return Shift;

}//end getShift

double ProductionWorker::getHourlyPay()

{

     return HourlyPay;

}//end getHourlyPay

class TeamLeader:public ProductionWorker

{

private: double MonthlyBonus;

     //variable to hold number of training hours required

           int TRequiredHours;

     //variable to hold number of training hours attended

             int TAttendHours;

public: //Default constructors

           TeamLeader()

      {

              MonthlyBonus=0.0;

              TRequiredHours=0;

              TAttendHours=0;

          }

          //Parameterized constructors

          TeamLeader(double MBonus,int TRhours,int TAhours)

          {

            MonthlyBonus=MBonus;

          TRequiredHours=TRhours;

          TAttendHours=TAhours;

          }

           void setMonthlyBonus(double);

          void setTRequiredHours(int);

          void setTAttendHours(int);

          double getMonthlyBonus();

          int getTRequiredHours();

          int getTAttendHours();

};

//Function definitions

void TeamLeader::setMonthlyBonus(double MBonus)

{

     MonthlyBonus=MBonus;

}

//end setMonthlyBonus

void TeamLeader::setTAttendHours(int Ahours)

{

    TAttendHours=Ahours;

}//end setTAttendHours

void TeamLeader::setTRequiredHours(int Rhours)

{

    TRequiredHours=Rhours;

}//end setTRequiredHours

double TeamLeader::getMonthlyBonus()

{

     return MonthlyBonus;

}//end getMonthlyBonus

int TeamLeader::getTAttendHours()

{

     return TAttendHours;

}//end getTAttendHours

int TeamLeader::getTRequiredHours()

{

     return TRequiredHours;

}//end getTRequiredHours

void main()

{

     TeamLeader lead1;

     int shift;

     double pay;

     int requiredHours,attendHours,Mbonus;

     //Inputting data

     lead1.setEmpName("Winston");

     lead1.setEmpNumber(562);

     lead1.setHireDate(" June:11");

     cout<<" 1-DayShift \n 2-Night"<

     cout<<"Enter shift:";

     cin>>shift;

     cout<<"Enter hourly pay:";

     cin>>pay;

     lead1.setShift(shift);

     lead1.setHourlyPay(pay);

     cout<<"Enter Montly Bonus:";

     cin>>Mbonus;

     cout<<"Enter Required Hours:";

     cin>>requiredHours;

     lead1.setTRequiredHours(requiredHours);

     cout<<"Enter Attended hours:";

     cin>>attendHours;

     lead1.setTAttendHours(attendHours);

     //Outputting Data

     cout<<"-----Team Lead Details-----"<

     cout<<"Name:"<

     cout<<"EmpNumber:"<

     cout<<"HireDate:"<

     cout<<"Shift:"<

     cout<<"Hourly Pay:"<

     cout<<"Monthly Bonus:"<

    

cout<<"Required TrainingHours:"

                   <

     cout<<"Attended Training Hours:"

                     <

     //To pause system for a while

     system("pause");

}

Add a comment
Know the answer?
Add Answer to:
Design a class named Employee. The class should keep the following information in
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA HELP Design a class named Employee. The class should keep the following information in fields:...

    JAVA HELP Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. Hire date then, Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab...

    C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab9b.cpp to the project. Copy and paste the code is listed below: Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information: Shift (an integer) Hourly pay rate (a double) // Specification file for the ProductionWorker Class #ifndef PRODUCTION_WORKER_H #define PRODUCTION_WORKER_H #include "Employee.h" #include <string> using namespace std; class ProductionWorker...

  • 7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName...

    7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailinglist The customer Number variable will be used to hold a unique integer for each customer. The mailing List variable should be a bool....

  • 7. PersonData and CustomerData classes Design a class  named PersonData with the following member variables...

    7. PersonData and CustomerData classes Design a class  named PersonData with the following member variables : lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables . Next, design a class  named CustomerData, which is derived from the PersonData class . The CustomerData class should have the following member variables : customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool....

  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • Using JAVA* Design a class named Person with fields for holding a person’s name, address, and...

    Using JAVA* Design a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class’s fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...

    (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...

  • this is java m. please use netbeans if you can. 7. Person and Customer Classes Design...

    this is java m. please use netbeans if you can. 7. Person and Customer Classes Design a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the cus- tomer wishes to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT