Question: Create a class called Salaried that is derived from Employee. Create a class called Hourly that is also derived from Employee. Override the base class

Create a class called Salaried that is derived from Employee.

Create a class called Hourly that is also derived from Employee.

Override the base class calculatePay() method.

Override the displayEmployee() method.

Create a class called Salaried that is derived from Employee. Create a

This is the Code I have so far and I keep getting the error 2005LNK

###############Benefits.h####################

#include

#include

using namespace std;

class Benefit {

public:

Benefit();

Benefit(string, double, int);

void displayBenefits();

string getHealthInsurance();

void setHealthInsurance(string);

double getLifeInsurance();

void setLifeInsurance(double);

int getVacation();

void setVacation(int);

private:

string healthInsurance;

double lifeInsurance;

int vacation;

};

#####################Employee.h#####################

#include

#include

using namespace std;

class Employee {

public:

Employee();

Employee(string, string, char, int, double);

void displayEmployee();

string getFirstName();

void setFirstName(string);

string getLastName();

void setLastName(string);

char getGender();

void setGender(char);

int getDependents();

void setDependents(int);

double getAnnualSalary();

void setAnnualSalary(double);

void setAnnualSalary(string);

static int getNumEmployees();

void setDependents(string);

private:

string firstName;

string lastName;

char gender;

int dependents;

double annualSalary;

static int numEmployee;

virtual double calculatePay();

};

##############hourly.h##################

#pragma once

#include "Employee.h"

class Hourly :

public Employee

{

public:

Hourly(void);

class Hourly : Employee

{

//Constant values for minimum, maximum wage and hours

private const double MIN_WAGE = 10;

private const double MAX_WAGE = 75;

private const double MIN_HOURS = 0;

private const double MAX_HOURS = 50;

private double wage; // wage of employee

private double hours; // hours worked

private string category; // category

//Noargument constructor

public Hourly()

: base()

{

wage = MIN_WAGE;

hours = MIN_HOURS;

category = "Not Given";

}//End of Noargument constructor.

//3-argument constructor

public Hourly(double wage, double hours, string category)

: base()

{

setWage(wage);

setHours(hours);

setCategory(category);

}//End of 3-Argument constructor

//8-argument cinstructor

public Hourly(string first, string last, char gen, int dep, double wage, double hours, Benefit ben, string category)

: base(first, last, gen, dep, wage * 1300, ben)

{

setWage(wage);

setHours(hours);

setCategory(category);

}// End of 8-argument constructor

//Helper functions to set wage, hours and category

public void setWage(double wage)

{

if (wage >= MIN_WAGE && wage

this.wage = wage;

else

this.wage = MIN_WAGE;

}//End of setWage

//Sets hours

public void setHours(double hours)

{

if (hours >= MIN_HOURS && hours

this.hours = hours;

else

this.hours = MIN_HOURS;

}//End of setHours

//Sets category

public void setCategory(string category)

{

if (category == "temporary" || category == "part time" || category == "full time")

this.category = category;

else

this.category = "temporary";

}//End of setCategory

//Overrides the base class method calculatePay

public override double CalculatePay()

{

return wage * hours;

}//End of CalculatePay method

//Overrides the base class ToString to display data of the object

public override string ToString()

{

return string.Format("Employee Type : {0} First Name : {1} Last Name : {2} Gender : {3} Dependents : {4} Category : {5} Wage : {6:c} Hours : {7} Weekly Pay : {8:c} Annual Salary : {9:c} {10}",

GetType().Name.ToUpper(), FirstName, LastName, (Gender == 'M') ? "Male" : "Female", Dependents, category, wage, hours, CalculatePay(), AnnualSalary, benefit.ToString());

}//End of ToString method

}//End of Hourly class

}//End of namespace

~Hourly(void);

};

########################salaried.h###############

const int MIN_MANAGEMENT_LEVEL = 0;

const int MAX_MANAGEMENT_LEVEL = 3;

const double BONUS_PERCENT = .10;

class Salaried :public Employee

{

protected:

int managementLevel;

public:

Salaried() :Employee()//initial the common employee attributes

{

managementLevel = MIN_MANAGEMENT_LEVEL;

}

Salaried(string firstName, string lastName, char gender, int dependents, double salary, Benefit benefits, int manLevel)

:Employee(firstName, lastName, gender, dependents, salary, benefits)

{

setManagementLevel(manLevel); //use the property to ensure valid data in the managementLevel attribute

}

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

{

Employee::setAnnualSalary(salary); //use the super class property to ensure valid data in the annual salary

setManagementLevel(manLevel);

}

void setManagementLevel(int manLevel)

{

if (manLevel >= MIN_MANAGEMENT_LEVEL && manLevel

{

managementLevel = manLevel;

}

else

{

managementLevel = MIN_MANAGEMENT_LEVEL;

}

}

int getManagementLevel()

{

return managementLevel;

}

double calculatePay()

{

return Employee::calculatePay() * (1 + (managementLevel*BONUS_PERCENT));

}

void displayEmployee()

{

Employee::displayEmployee();

cout

cout

}

};

####################Employee.cpp################

#include

#include

#include "Employee.h"

#include "Benefits.h"

using namespace std;

int Employee::numEmployee=0;

Employee::Employee() {

firstName = "not given";

lastName = "not given";

gender = 'U';

dependents = 0;

annualSalary = 20000;

numEmployee++;

}

Employee::Employee(string first, string last, char gen, int dep,

double salary) {

firstName = first;

lastName = last;

gender = gen;

dependents = dep;

annualSalary = salary;

numEmployee++;

}

Benefit::Benefit() {

healthInsurance=" not given";

lifeInsurance=0;

vacation=0;

}

Benefit::Benefit(string hInsurance, double lInsurance, int vacationDays){

healthInsurance=hInsurance;

lifeInsurance=lInsurance;

vacation=vacationDays;

}

string Benefit::getHealthInsurance() {

return healthInsurance;

}

double Benefit::getLifeInsurance() {

return lifeInsurance;

}

int Benefit::getVacation() {

return vacation;

}

void Benefit::setHealthInsurance(string hInsurance){

healthInsurance=hInsurance;

}

void Benefit::setLifeInsurance(double lInsurance) {

lifeInsurance=lInsurance;

}

void Benefit::setVacation(int vacationDays) {

vacation=vacationDays;

}

string Employee::getFirstName() {

return firstName;

}

string Employee::getLastName() {

return lastName;

}

void Employee::setFirstName(string fname) {

firstName = fname;

}

void Employee::setLastName(string lname) {

lastName = lname;

}

char Employee::getGender() {

return gender;

}

void Employee::setGender(char gen) {

switch (gen) {

case 'f':

case 'F':

case 'M':

case 'm':

gender = gen;

break;

default:

gender = 'U';

}

}

void Employee::setDependents(int dep) {

dependents = dep;

}

double Employee::getAnnualSalary() {

return annualSalary;

}

void Employee::setAnnualSalary(double salary) {

annualSalary = salary;

}

double Employee::calculatePay() {

return (annualSalary / 52);

}

int Employee::getNumEmployees()

{

return numEmployee;

}

void Employee::displayEmployee() {

cout

cout

cout

cout

cout

cout

cout

}

void Benefit::displayBenefits() {

cout

cout

cout

cout

cout

}

##################Employeetest.cpp

#include "Employee.cpp"

#include

#include

#include

#include

using namespace std;

int main() {

cout

cout

cout

Employee emp;

string first;

string last;

string gen;

string dependents;

string salary;

Benefit ben;

string healthInsurance;

double lifeInsurance;

int vacation;

cout

cin >> first;

cout

cin >> last;

cout

cin >> gen;

cout

cin >> dependents;

cout

cin >> salary;

cout

cin >> healthInsurance;

cout

cin >> lifeInsurance;

cout

cin >> vacation;

emp.setFirstName(first);

emp.setLastName(last);

emp.setDependents(atoi(dependents.c_str()));

emp.setAnnualSalary(atof(salary.c_str()));

ben.setHealthInsurance(healthInsurance);

ben.setLifeInsurance(lifeInsurance);

ben.setVacation(vacation);

if (gen == "Female") {

emp.setGender('F');

} else if (gen == "Male") {

emp.setGender('M');

} else {

emp.setGender('U');

}

emp.displayEmployee();

cout

Employee emp2("Mary", "Noia", 'F', 5, 24000.0);

emp2.displayEmployee();

emp2.setFirstName(first);

emp2.setLastName(last);

emp2.setDependents(atoi(dependents.c_str()));

emp2.setAnnualSalary(atof(salary.c_str()));

ben.setHealthInsurance(healthInsurance);

ben.setLifeInsurance(lifeInsurance);

ben.setVacation(vacation);

if (gen == "Female") {

emp2.setGender('F');

} else if (gen == "Male") {

emp2.setGender('M');

} else {

emp2.setGender('U');

}

emp2.displayEmployee();

ben.displayBenefits();

cout

system("pause");

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!