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

#include <conio.h> #include <iostream> #include <string> #include <cstdlib> usin

ID: 3759725 • Letter: #

Question

#include <conio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

//Header for class Employee
class Employee
{
public:
Employee();
Employee(string lastname, string firstname, string newSSN);
void changeName(string last, string first);
void changeSSN(string newSSN);
void printCheck();
protected:
string lastname;
string firstname;
string ssn;
};

//Header for Hourly Employee class
class HourEmp : public Employee
{
public:
HourEmp();
HourEmp(string lname, string fname, string newSSN,
double newWage, double new_hours);
void setWage(double newWage);
double getWage();
void setHours(double hours_worked);
double getHours();
void giveRaise(double amount);
void printCheck();
private:
double Raise;
double wageRate;
double hours;
};

//Header for Salaried Employee class
class SalEmp : public Employee
{
public:
SalEmp();
SalEmp(string lname, string fname, string newSSN,
double newSalary);
double getSalary();
void changeSalary(double new_salary);
void giveRaise(double amount);
void printCheck();
private:
double salary;
double raise;
};

//Header for Titled Employee class
class titlEmp: public Employee{
private:
string Title;
public:
titlEmp();
titlEmp(string lastname, string firstname, string newSSN, string title);
string getTitle();
void setTitle(string title);
void changeName();
void printCheck();
};

//Program for testing base and derived classes
int main()
{

cout << "Press enter after each entry." << endl;
Employee emp;
emp.printCheck();
cout << endl;

cout << "**** HOURLY EMOLOYEE INFORMATION ****" << endl;
HourEmp hemp;
hemp.printCheck();
hemp.giveRaise(0);
hemp.printCheck();
cout << endl;

cout << "**** SALARIED EMOPLOYEE INFORMATION ****" << endl;
SalEmp semp;
semp.printCheck();
semp.giveRaise(0);
semp.printCheck();

cout << "**** TITLED EMPLOYEE INFORMATION ****" << endl;
titlEmp temp;
temp.printCheck();
temp.changeName();
temp.printCheck();

system("PAUSE");

return 0;
}

//**********************************
// Implementation for class Employee
//**********************************
Employee::Employee()
{
cout << "Employee last name: ";
cin >> lastname;
cout << "Employee first name: ";
cin >> firstname;
cout << "Employee SSN: ";
cin >> ssn;
cout << endl;
}

Employee::Employee(string lname, string fname, string new_number)
{
lastname = lname;
firstname = fname;
ssn = new_number;
}

void Employee::changeName(string lname, string fname)
{
lastname = lname;
firstname = fname;
}

void Employee::changeSSN(string new_num)
{ssn = new_num;}

void Employee::printCheck()
{
cout << firstname << " " << lastname << endl;
cout << "Cannot print check for employee of unknown type" << endl << endl;
}

//***************************************
//Implementation for Hourly Employee class
//***************************************
HourEmp::HourEmp() : Employee()
{
cout << "Hourly wage: ";
cin >> wageRate;
cout << "Number of hours worked: ";
cin >> hours;
}

HourEmp::HourEmp(string lname, string fname, string new_num,
double newWage, double new_hours)
: Employee(lname, fname, new_num)
{
wageRate = newWage;
hours = new_hours;
}

void HourEmp::setWage(double newWage)
{wageRate = newWage;}

double HourEmp::getWage()
{return wageRate;}

void HourEmp::setHours(double hours_worked)
{hours = hours_worked;}

double HourEmp::getHours()
{return hours;}

void HourEmp::giveRaise(double amount)
{
cout << "Raise: ";
cin >> Raise;
wageRate = wageRate + amount + Raise;
}

void HourEmp::printCheck()
{
double net_pay;
net_pay = hours * wageRate;
cout << endl;
cout << "--------------------------------------" << endl;
cout << "************ PAY CHECK ************" << endl;
cout << "Pay to the order of: " << firstname << " " << lastname << endl;
cout << "Pay amount: " << net_pay << " Dollars" << endl;
cout << "Employee Number: " << ssn << endl;
cout << "Hourly Employee - Hours worked: " << hours
<< " Rate: " << wageRate << " Pay: " << net_pay << endl;
cout << "--------------------------------------" << endl << endl;
}

//*****************************************
//Implementation for Salaried Employee class
//*****************************************
SalEmp::SalEmp() : Employee()
{
cout << "Weekly Salary: ";
cin >> salary;
cout << endl;
}

SalEmp::SalEmp(string lname, string fname, string newSSN,
double new_pay)
: Employee(lname, fname, newSSN),
salary(new_pay)
{
}

void SalEmp::giveRaise(double amount)
{
cout << "Raise: ";
cin >> raise;
salary = salary + raise + amount;
}

double SalEmp::getSalary()
{return salary;}

void SalEmp::changeSalary(double new_salary)
{salary = new_salary;}

void SalEmp::printCheck()
{
double net_pay;
net_pay = salary;
cout << endl;
cout << "--------------------------------------" << endl;
cout << "************ PAY CHECK ************" << endl;
cout << "Pay to the order of " << firstname << " " << lastname << endl;
cout << "Pay amount " << net_pay << " Dollars" << endl;
cout << "--------------------------------------" << endl;
cout << "Employee Number: " << ssn << endl;
cout << "Salaried Employee - Regular Pay: " << salary << endl;
cout << "--------------------------------------" << endl << endl;
}

//***************************************
//Implementation for Titled Employee class
//***************************************
titlEmp::titlEmp() : Employee()
{
cout << "Enter Titled Employee's title";
cin >> Title;
cout << endl;
}

titlEmp::titlEmp(string lastname, string firstname, string newSSN, string title): Employee(lastname, firstname, newSSN)   
{Title = title;}

string titlEmp::getTitle()
{return Title;}

void titlEmp::setTitle(string title)
{Title = title;}

void titlEmp::printCheck()
{
cout << endl;
cout << "--------------------------------------" << endl;
cout << "************ PAY CHECK ************" << endl;
cout << "Pay to the order of " << firstname << " " << lastname << endl;
cout << "--------------------------------------" << endl;
cout << "Employee Number: " << ssn << endl;
cout << "Titled Employee - Title: " << Title << endl;
cout << "--------------------------------------" << endl;
}

void titlEmp::changeName()
{
string lastname,firstname;
cout << "Employee's new last name: ";
cin >> lastname;
cout << "Employee's new first name: ";
cin >> firstname;
Employee::changeName(lastname, firstname);
cout << "Employee's new Title: ";
cin >> Title;
}

*****************************************************************************************************
*****************************************************************************************************

MODIFY THE ABOVE CODE TO DO THE FOLLOWING:

1. Use composition to add a Date Hired to the base class Employee. Use an include statement to include your Date class code in the Employee class definition (minus the main program, of course!)

2. Modify the constructors for Employee to include the Date Hired information, consistent with their current implementation. You will also have to modify some of the derived class constructors to properly include the date hired data.

3. Provide a new member function to allow the user of the Employee class to change an Employee’s date of hire.

4. Modify the existing Employee base class print check function. Instead of printing an error message, have the base class print check function print a well-formatted heading for a paycheck, including the employee name, employee number, and date hired.

5. Modify each derived class’s print check function to call the base class print check function first (to print the check heading), then calculate and print the paycheck information. You may repeat the employee name in the "Pay to the Order Of . . ." portion of the paycheck. Repeating the SSN is not needed.

6. Update your main function tests of the employee, hourly employee, salaried employee, and titled employee as needed to include date of hire information.

7. Update your main function tests to also include a test for changing an employee date of hire. Do this using an invalid date as well as a valid date. As always, your test cases should be labeled in the program output.

PLEASE DO NOT PARTIALLY ANSWER THIS QUESTION

Explanation / Answer

#include <conio.h>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
//Header for class Employee
class Employee
{
public:
Employee();
Employee(string lastname, string firstname, string newSSN);
void changeName(string last, string first);
void changeSSN(string newSSN);
void printCheck();
protected:
string lastname;
string firstname;
string ssn;
};
//Header for Hourly Employee class
class HourEmp : public Employee
{
public:
HourEmp();
HourEmp(string lname, string fname, string newSSN,
double newWage, double new_hours);
void setWage(double newWage);
double getWage();
void setHours(double hours_worked);
double getHours();
void giveRaise(double amount);
void printCheck();
private:
double Raise;
double wageRate;
double hours;
};
//Header for Salaried Employee class
class SalEmp : public Employee
{
public:
SalEmp();
SalEmp(string lname, string fname, string newSSN,
double newSalary);
double getSalary();
void changeSalary(double new_salary);
void giveRaise(double amount);
void printCheck();
private:
double salary;
double raise;
};
//Header for Titled Employee class
class titlEmp: public Employee{
private:
string Title;
public:
titlEmp();
titlEmp(string lastname, string firstname, string newSSN, string title);
string getTitle();
void setTitle(string title);
void changeName();
void printCheck();
};
//Program for testing base and derived classes
int main()
{
cout << "Press enter after each entry." << endl;
Employee emp;
emp.printCheck();
cout << endl;
cout << "**** HOURLY EMOLOYEE INFORMATION ****" << endl;
HourEmp hemp;
hemp.printCheck();
hemp.giveRaise(0);
hemp.printCheck();
cout << endl;
cout << "**** SALARIED EMOPLOYEE INFORMATION ****" << endl;
SalEmp semp;
semp.printCheck();
semp.giveRaise(0);
semp.printCheck();
cout << "**** TITLED EMPLOYEE INFORMATION ****" << endl;
titlEmp temp;
temp.printCheck();
temp.changeName();
temp.printCheck();
system("PAUSE");
return 0;
}
//**********************************
// Implementation for class Employee
//**********************************
Employee::Employee()
{
cout << "Employee last name: ";
cin >> lastname;
cout << "Employee first name: ";
cin >> firstname;
cout << "Employee SSN: ";
cin >> ssn;
cout << endl;
}
Employee::Employee(string lname, string fname, string new_number)
{
lastname = lname;
firstname = fname;
ssn = new_number;
}
void Employee::changeName(string lname, string fname)
{
lastname = lname;
firstname = fname;
}
void Employee::changeSSN(string new_num)
{ssn = new_num;}
void Employee::printCheck()
{
cout << firstname << " " << lastname << endl;
cout << "Cannot print check for employee of unknown type" << endl << endl;
}
//***************************************
//Implementation for Hourly Employee class
//***************************************
HourEmp::HourEmp() : Employee()
{
cout << "Hourly wage: ";
cin >> wageRate;
cout << "Number of hours worked: ";
cin >> hours;
}
HourEmp::HourEmp(string lname, string fname, string new_num,
double newWage, double new_hours)
: Employee(lname, fname, new_num)
{
wageRate = newWage;
hours = new_hours;
}
void HourEmp::setWage(double newWage)
{wageRate = newWage;}
double HourEmp::getWage()
{return wageRate;}
void HourEmp::setHours(double hours_worked)
{hours = hours_worked;}
double HourEmp::getHours()
{return hours;}
void HourEmp::giveRaise(double amount)
{
cout << "Raise: ";
cin >> Raise;
wageRate = wageRate + amount + Raise;
}
void HourEmp::printCheck()
{
double net_pay;
net_pay = hours * wageRate;
cout << endl;
cout << "--------------------------------------" << endl;
cout << "************ PAY CHECK ************" << endl;
cout << "Pay to the order of: " << firstname << " " << lastname << endl;
cout << "Pay amount: " << net_pay << " Dollars" << endl;
cout << "Employee Number: " << ssn << endl;
cout << "Hourly Employee - Hours worked: " << hours
<< " Rate: " << wageRate << " Pay: " << net_pay << endl;
cout << "--------------------------------------" << endl << endl;
}
//*****************************************
//Implementation for Salaried Employee class
//*****************************************
SalEmp::SalEmp() : Employee()
{
cout << "Weekly Salary: ";
cin >> salary;
cout << endl;
}
SalEmp::SalEmp(string lname, string fname, string newSSN,
double new_pay)
: Employee(lname, fname, newSSN),
salary(new_pay)
{
}
void SalEmp::giveRaise(double amount)
{
cout << "Raise: ";
cin >> raise;
salary = salary + raise + amount;
}
double SalEmp::getSalary()
{return salary;}
void SalEmp::changeSalary(double new_salary)
{salary = new_salary;}
void SalEmp::printCheck()
{
double net_pay;
net_pay = salary;
cout << endl;
cout << "--------------------------------------" << endl;
cout << "************ PAY CHECK ************" << endl;
cout << "Pay to the order of " << firstname << " " << lastname << endl;
cout << "Pay amount " << net_pay << " Dollars" << endl;
cout << "--------------------------------------" << endl;
cout << "Employee Number: " << ssn << endl;
cout << "Salaried Employee - Regular Pay: " << salary << endl;
cout << "--------------------------------------" << endl << endl;
}
//***************************************
//Implementation for Titled Employee class
//***************************************
titlEmp::titlEmp() : Employee()
{
cout << "Enter Titled Employee's title";
cin >> Title;
cout << endl;
}
titlEmp::titlEmp(string lastname, string firstname, string newSSN, string title): Employee(lastname, firstname, newSSN)   
{Title = title;}
string titlEmp::getTitle()
{return Title;}
void titlEmp::setTitle(string title)
{Title = title;}
void titlEmp::printCheck()
{
cout << endl;
cout << "--------------------------------------" << endl;
cout << "************ PAY CHECK ************" << endl;
cout << "Pay to the order of " << firstname << " " << lastname << endl;
cout << "--------------------------------------" << endl;
cout << "Employee Number: " << ssn << endl;
cout << "Titled Employee - Title: " << Title << endl;
cout << "--------------------------------------" << endl;
}
void titlEmp::changeName()
{
string lastname,firstname;
cout << "Employee's new last name: ";
cin >> lastname;
cout << "Employee's new first name: ";
cin >> firstname;
Employee::changeName(lastname, firstname);
cout << "Employee's new Title: ";
cin >> Title;
}