Question: C++ I need my existing code updated with the following: STEP 1 Notice in the updated UML diagram that the Employee class is designated as

C++

I need my existing code updated with the following:

STEP 1 Notice in the updated UML diagram that the Employee class is designated as abstract by having the class name Employee italicized. Also, the calculatePay method is italicized, which means that it is a pure virtual function and needs to be implemented in the derived classes. In addition, make displayEmployee() method a pure virtual function as well.

C++ I need my existing code updated with the following: STEP 1

STEP 2 Modify the Employee Class

1. Define calculatePay() as a pure virtual function.

2. Define displayEmployee() as a pure virtual function.

3. When class Employee contains two pure virtual functions, it becomes an abstract class.

STEP 3 Create Generalized Input Methods

1. Reuse method getInput() from the previous Lab to prompt the user to enter Employee information.

STEP 4 Modify the Main Method

Create two employee pointers with:

Notice in the updated UML diagram that the Employee class is designated

The first employee pointer refers to a salaried employee and the second employee pointer refers to a hourly employee.

Prompt the user to enter information for these two pointers and display the calculated result.

STEP 5 SAMPLE OUTPUT OF WHAT THE PROGRAM SHOULD LOOK LIKE WHEN FINISHED

as abstract by having the class name Employee italicized. Also, the calculatePay

MY CODE THAT NEEDS TO BE UPDATED:

#include

#include

#include

#include

using namespace std;

class Benefit {

private:

string healthinsurance;

double lifeinsurance;

int vacation;

public:

Benefit() {

healthinsurance = "";

lifeinsurance = 0;

vacation = 0;

}

Benefit(string health, double life, int vaca) {

healthinsurance = health;

lifeinsurance = life;

vacation = vaca;

}

//method that displays employee information

void displayBenefits()

{

cout

cout

cout

cout

cout

}

void setHealthInsurance(string hins) {

healthinsurance = hins;

}

string getHealthInsurance() {

return healthinsurance;

}

void setLifeInsurance(double lifeins) {

lifeinsurance = lifeins;

}

double getLifeInsurance() {

return lifeinsurance;

}

void setVacation(int vaca) {

vacation = vaca;

}

int getVacation() {

return vacation;

}

};

/*class iEmployee {

public:

virtual double calculatePay() = 0;

};*/

class Employee //: public iEmployee

{

protected:

static int numEmployees;

//member variables of Employee class

protected:

string firstName;

string lastName;

char gender;

int dependents;

double annualSalary;

public:

Benefit benefit;

//default constructor

Employee()

{

//set the member variables to default values

firstName = "not given";

lastName = "not given";

gender = 'U';

dependents = 0;

annualSalary = 20000;

//Incrementing number of employees

numEmployees += 1;

}

//constructor with parameters

Employee(string first, string last, char gen, int dep, double salary, Benefit benef)

{

//set the member variables to values passed

firstName = first;

lastName = last;

gender = gen;

dependents = dep;

annualSalary = salary;

//Incrementing number of employees

numEmployees += 1;

benefit = benef;

}

//getter methods

//method that gets firstName

string getfirstName()

{

return firstName;

}

//method that gets lastName

string getlastName()

{

return lastName;

}

//method that gets gender

char getGender()

{

return gender;

}

//method that gets dependents

int getdependents()

{

return dependents;

}

//method that gets annual salary

double getannualSalary()

{

return annualSalary;

}

//setter methods

//method that sets firstname

void setfirstName(string first)

{

firstName = first;

}

//method that sets lastname

void setlastName(string last)

{

lastName = last;

}

//method that sets gender

void setGender(char gen)

{

gender = gen;

}

//method that sets dependents

void setdependents(int dep)

{

dependents = dep;

}

//method that sets annual salary

void setannualSalary(double salary)

{

annualSalary = salary;

}

//Overloaded method that sets dependents

void setdependents(string dep)

{

dependents = stoi(dep);

}

//Overloaded method that sets annual salary

void setannualSalary(string salary)

{

annualSalary = stod(salary);

}

//method that calculates weekly pay

double calculatePay()

{

//calculate and return weekly pay

return annualSalary / 52;

}

//Static method

static int getNumEmployees()

{

//Return number of employee objects created

return numEmployees;

}

//method that displays employee information

void displayEmployee()

{

cout

cout

cout

cout

cout

cout

cout

cout

benefit.displayBenefits();

}

};

int Employee::numEmployees = 0;

class Salaried :public Employee

{

const int MIN_MANAGEMENT_LEVEL = 0;

const int MAX_MANAGEMENT_LEVEL = 3;

const double BONUS_PERCENT = .10;

int managementLevel;

public:

Salaried() :Employee()

{

managementLevel = MIN_MANAGEMENT_LEVEL;

}

Salaried(string fname, string lname, char gen, int dep, double salary, Benefit ben, int manLevel) :Employee(fname, lname, gen, dep, salary, ben)

{

firstName = fname;

lastName = lname;

gender = gen;

dependents = dep;

annualSalary = salary;

benefit = ben;

if (manLevel > MAX_MANAGEMENT_LEVEL && manLevel

managementLevel = MIN_MANAGEMENT_LEVEL;

else

managementLevel = manLevel;

}

Salaried(double sal, int manLevel) :Employee()

{

annualSalary = sal;

if (manLevel > MAX_MANAGEMENT_LEVEL && manLevel

managementLevel = MIN_MANAGEMENT_LEVEL;

else

managementLevel = manLevel;

}

double calculatePay()

{

return annualSalary / 52 + managementLevel*BONUS_PERCENT;

}

void setmanagementLevel(int manLevel)

{

if (manLevel > MAX_MANAGEMENT_LEVEL && manLevel

managementLevel = MIN_MANAGEMENT_LEVEL;

else

managementLevel = manLevel;

}

void displayEmployee()

{

cout

cout

cout

cout

cout

cout

cout

cout

cout

benefit.displayBenefits();

}

};

class Hourly :public Employee

{

const double MIN_WAGE = 10;

const double MAX_WAGE = 75;

const double MIN_HOURS = 0;

const double MAX_HOURS = 50;

double wage;

double hours;

string category;

public:

Hourly() :Employee()

{

wage = MIN_WAGE;

hours = MIN_HOURS;

category = "NOT ASSIGNED";

}

void setWage(double wage)

{

if (wage > MAX_WAGE && wage

this->wage = MIN_WAGE;

else

this->wage = wage;

}

void setHours(double hours)

{

if (hours > MAX_HOURS && hours

this->hours = MIN_HOURS;

else

this->hours = hours;

}

void setCategory(string category)

{

if (category._Equal("temporay") && category._Equal("part time") && category._Equal("full time"))

this->category = category;

else

category = "temporary";

}

Hourly(double wage, double hours, string category) :Employee()

{

if (wage > MAX_WAGE && wage

this->wage = MIN_WAGE;

else

this->wage = wage;

if (hours > MAX_HOURS && hours

this->hours = MIN_HOURS;

else

this->hours = hours;

if (category._Equal("temporay") || category._Equal("part time") || category._Equal("full time"))

this->category = category;

else

category = "temporary";

}

Hourly(string fname, string lname, char gen, int dep, double wage, double hours, Benefit ben, string category)

:Employee(fname, lname, gen, dep, wage, ben)

{

if (hours > MAX_HOURS && hours

this->hours = MIN_HOURS;

else

this->hours = hours;

if (category._Equal("temporay") || category._Equal("part time") || category._Equal("full time"))

this->category = category;

else

category = "temporary";

}

double calculatePay()

{

return wage * hours;

}

void setannualSalary(double salary)

{

annualSalary = salary * 50;

}

void displayEmployee()

{

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

benefit.displayBenefits();

}

};

int main()

{

//display banner

cout

cout

cout

//declare object for Employee

Salaried emp1;

Hourly worker;

string fname, lname;

string gender, dependents, salstr, healthins, category;

double sal, lifeinsur, wage, hours;

int vacation, manLevel;

//prompt and read employee information

cout

cin >> fname;

cout

cin >> lname;

cout

cin >> gender;

cout

cin >> dependents;

cout

cin >> salstr;

cout

cin >> healthins;

cout

cin >> lifeinsur;

cout

cin >> vacation;

cout

cin >> manLevel;

emp1.setmanagementLevel(manLevel);

emp1.benefit.setHealthInsurance(healthins);

emp1.benefit.setLifeInsurance(lifeinsur);

emp1.benefit.setVacation(vacation);

//set the employee information using setter methodds

emp1.setfirstName(fname);

emp1.setlastName(lname);

emp1.setGender(gender[0]);

/* Calling the new overloaded setters */

emp1.setdependents(dependents);

emp1.setannualSalary(salstr);

//display employee info

emp1.displayEmployee();

//prompt and read employee information

cout

cin >> fname;

cout

cin >> lname;

cout

cin >> gender;

cout

cin >> dependents;

cout

cin >> sal;

cout

cin >> healthins;

cout

cin >> lifeinsur;

cout

cin >> vacation;

cout

cin >> hours;

cout

cin >> wage;

cout

cin >> category;

worker.setannualSalary(sal);

worker.setWage(wage);

worker.setHours(hours);

worker.setCategory(category);

worker.benefit.setHealthInsurance(healthins);

worker.benefit.setLifeInsurance(lifeinsur);

worker.benefit.setVacation(vacation);

//set the employee information using setter methodds

worker.setfirstName(fname);

worker.setlastName(lname);

worker.setGender(gender[0]);

/* Calling the new overloaded setters */

worker.setdependents(dependents);

emp1.setannualSalary(salstr);

//display employee info

worker.displayEmployee();

//Calling and displaying number of employee objects created

cout

cout

Benefit ben("North West Mutual", 5000000, 14);

//create second object for Employee

//pass employee information as parameters

Employee emp2 = Employee("Mary", "Noia", 'F', 2, 150000, ben);

cout

//display employee info

emp2.displayEmployee();

//Calling and displaying number of employee objects created

cout

cout

cout

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!