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

Employee and ProductionWorker Classes Design a class named Employee. The class s

ID: 3813583 • Letter: E

Question

Employee and ProductionWorker Classes 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 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 hold the following information: * Shift (An integer) * Hourly pay rate(A double) The workday is divided into two shifts: day and night. The shift field will be 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 methods for the class. Demonstrate the classes by writing a program that uses a ProductionWorker object. (C++ language please)

Explanation / Answer

#include<iostream>
#include<cstring>

using namespace std;

class Employee {

public: char eName[20], eNum[20], hireDate[20];

public:
  
   Employee(){
   }
  
   Employee(const char* Name,const char* Num,const char* hireDat){    
memcpy(eName, Name,20);
memcpy(eNum,Num,20);
memcpy(hireDate,hireDat,20);

}
public: void setEName(const char* Name){
memcpy(eName, Name,20);
}
public: char* getEName(){
  
return eName;
}

public :
   void setENum(char* Num){
memcpy(eNum,Num,20);
}
public:const char* getENum(){
return eNum;
}

public: void setHireDate(char* hireDat){
memcpy(hireDate,hireDat,20);
}
public: const char* getHireDate(){
return hireDate;
}
};

class ProductionWorker : public Employee{

private :int shift, hoursWorked;
private :double payRate;

public :

   ProductionWorker(const char* eName,const char* eNum,const char* hireDate, int shift,
int hoursWorked, double payRate) {
Employee(eName, eNum, hireDate);
setShift(shift);
setPayRate(payRate);
setHoursWorked(hoursWorked);
}

public :int getShift() {
return shift;
}
public :void setShift(int shif) {
shift = shif;
}

public :int getHoursWorked() {
return hoursWorked;
}
public :void setHoursWorked(int hoursWorke) {
hoursWorked = hoursWorke;
}

public :double getPayRate() {
return payRate;
}
public :void setPayRate(double payRte) {
payRate = payRte;
}

public : void tochar(){
if (shift == 1){
double pay = payRate * (int)hoursWorked;
cout<< "Employee name: " << eName << " Employee number: " << eNum
<< " Hire date: " << hireDate << " Shift: " << getShift() <<
" Hourly pay Rate: " << getPayRate() << " Hours worked: " << getHoursWorked()
<< " Pay for the week: " << pay << " ";
}
else if (shift == 2){
double pay = payRate * 1.25 * (int)hoursWorked;
cout<< "Employee name: " << eName<< " Employee number: " << eNum
<< " Hire date: " << hireDate << " Shift: " << getShift() <<
" Hourly pay Rate: " << getPayRate() << " Hours worked: " << getHoursWorked()
<< " Pay for the week: " << pay << " ";
}
else cout<< "Invalid shift number.";
}
};

int main(){
  
ProductionWorker eList1("Bill", "234-H", "10/31/2010", 1, 10, 40);
ProductionWorker eList2("Joe", "651-J", "11/23/2011", 2, 13, 26);
ProductionWorker eList3("Sandy", "492-B", "05/20/2009", 2, 16, 32);
ProductionWorker eList4("Sherry", "123-A", "08/05/2000", 1, 20, 38);
  
eList1.tochar();
eList2.tochar();
eList3.tochar();
eList4.tochar();
  
   return 0;
}

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