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

C++ //Please provide the updated code and sample output from visual studios //I

ID: 3869469 • Letter: C

Question

C++

//Please provide the updated code and sample output from visual studios

//I need my existing code updated with the following changes:

UML DIAGRAMS

MODIFY THE EMPLOYEE CLASS:

Using the updated Employee class diagram, modify the attributes to be protected.

Delete the iEmployee interface class, and remove the reference from the Employee class.

CREATE THE SALARIED CLASS:

Using the UML Diagrams, create the Salaried classes, ensuring to specify that the Salary class inherits from the Employee class.

For each of the constructors listed in the Salaried class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter.

The valid management levels are 0, 1, 2, and 3, and should be implemented as a constant.

Override the calculatePay method to add a 10 percent bonus for each of the management levels (i.e., bonus percentage = managementLevel * .10). The bonus percentage should be implemented as a constant.

Override the displayEmployee() method to add the management level to the employee information.

CREATE THE HOURLY CLASS:

Using the UML Diagrams, create the Hourly classes, ensuring to specify that the Hourly class inherits from the Employee class.

For each of the constructors listed in the Hourly class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter.

The valid category types are "temporary", "part time", and "full time".

The provided hours must be more than 0 hours and less than 50 hours, and the limits should be implemented as constants.

The provided wage must be between 10 and 75, and the limits should be implemented as constants.

Override the calculatePay method by multiplying the wages by the number of hours.

Override the Employee setAnnualSalary method and set the annual salary by multiplying the weekly pay by 50.

Override the displayEmployee() method to add the category to the hourly employee information.

MODIFY THE MAIN METHOD:

For each object created, display the number of employees created.

For each object created, write statements to exercise each of the public methods listed in the Class diagram.

For each object created, invoke the object's displayEmployee() method to display the employee's information.

SAMPLE OUTPUT OF WHAT THE PROGRAM SHOULD LOOK LIKE:

MY EXISTING CODE THAT NEEDS UPDATED:

#include<iostream>

#include<iomanip>

#include<stdlib.h>

#include<sstream>

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 << " Benefit Information ";

              cout << "________________________________________________________________ ";

              cout << " Health Insurance: " << healthinsurance;

              cout << " Life Insurance: " << fixed << setprecision(2) << lifeinsurance;

              cout << " Vacation: " << vacation << " days";

       }

       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

private:

       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 << " Employee Information ";

              cout << "________________________________________________________________ ";

              cout << " Name: " << firstName << " " << lastName;

              cout << " Gender: " << gender;

              cout << " Dependents: " << dependents;

              cout << " Annual Salary: " << fixed << setprecision(2) << annualSalary;

              cout << " Weekly Salary: " << fixed << setprecision(2) << calculatePay();

              cout << " ";

              benefit.displayBenefits();

       }

};

int Employee::numEmployees = 0;

int main()

{

       //display banner

       cout << "Welcome to your first Object Oriented Program--Employee ClassCIS247C, Week 5 Lab";

       cout << "Name: ";

       cout << " ******************** Employee 1 ******************** ";

       //declare object for Employee

       Employee emp1;

       string fname, lname;

       string gender, dependents, salstr, healthins;

       double sal, lifeinsur;

       int vacation;

       //prompt and read employee information

       cout << "Please enter your First Name ";

       cin >> fname;

       cout << "Please enter your Last Name ";

       cin >> lname;

       cout << "Please enter your Gender ";

       cin >> gender;

       cout << "Please enter your Dependents ";

       cin >> dependents;

       cout << "Please enter your Annual Salary ";

       cin >> salstr;

       cout << "Please enter your Health insurance ";

       cin >> healthins;

       cout << "Please enter your life insurance ";

       cin >> lifeinsur;

       cout << " Please enter your vacation days ";

       cin >> vacation;

       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();

       //Calling and displaying number of employee objects created

       cout << " --- Number of Employee Object Created ---- ";

       cout << "Number of Employees : " << Employee::getNumEmployees() << " ";

       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 << " ******************** Employee 2 ******************** ";

       //display employee info

       emp2.displayEmployee();

       //Calling and displaying number of employee objects created

       cout << " --- Number of Employee Object Created ---- ";

       cout << "Number of Employees : " << Employee::getNumEmployees() << " ";

       cout << " The end of the CIS247C Week5 iLab.";

       return 0;

}

Benefit Emplovee -healthinsurance string -lifeinsurance double vacation:int +Benefit) +Benefit (in hins: string, in lins double, in vac: int) +displayBenefits: void #firstName- string #lastName : string #gender : char #dependents : int #annu #benefit . Benefit static numEmployees : int 0 +Employee) +Employee(in fname string, in Iname string, in gen: char, in dep: int, in benefits : Benefit) +static getNumEmployees): int +CalculatePay) : double +displayEmployee) void alSalary double Salaried MIN MANAGEMENT LEVEL: int=0 MAX MANAGEMENT LEVEL: int=3 BONUS PERCENT : double= 10 -managementLeve int +Salaried) +Salaried(in fname string, in Iname string, in gen: char, in dep int, in sal: double, in ben : Benefit, in manLevel int) +Salaried(in sal : double, in manLevel int) +CalculatePay): double +displayEmployee) void Hourl MIN WAGE: double= 10 MAX WAGE : double = 75 MIN HOURS: double=0 MAX HOURS: double = 50 wage double -hours: double -cate +Hourly +Hourly (in wage double, in hours double, in category string) +Hourly (in fname: string, in Iname string, in gen: char, in dep: int, in wage double, in hours : double, in ben: Benefit, in category string) +CalculatePay): double +displayEmployee) void strin

Explanation / Answer

#include<iostream>

#include<iomanip>

#include<stdlib.h>

#include<sstream>

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 << " Benefit Information ";

cout << "________________________________________________________________ ";

cout << " Health Insurance: " << healthinsurance;

cout << " Life Insurance: " << fixed << setprecision(2) << lifeinsurance;

cout << " Vacation: " << vacation << " days";

}

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 << " Employee Information ";

cout << "________________________________________________________________ ";

cout << " Name: " << firstName << " " << lastName;

cout << " Gender: " << gender;

cout << " Dependents: " << dependents;

cout << " Annual Salary: " << fixed << setprecision(2) << annualSalary;

cout << " Weekly Salary: " << fixed << setprecision(2) << calculatePay();

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 < MIN_MANAGEMENT_LEVEL)

managementLevel = MIN_MANAGEMENT_LEVEL;

else

managementLevel = manLevel;

}

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

{

annualSalary = sal;

if (manLevel > MAX_MANAGEMENT_LEVEL && manLevel < MIN_MANAGEMENT_LEVEL)

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 < MIN_MANAGEMENT_LEVEL)

managementLevel = MIN_MANAGEMENT_LEVEL;

else

managementLevel = manLevel;

}

void displayEmployee()

{

cout << " Employee Information ";

cout << "________________________________________________________________ ";

cout << " Name: " << firstName << " " << lastName;

cout << " Gender: " << gender;

cout << " Dependents: " << dependents;

cout << " Management Level : " << managementLevel;

cout << " Annual Salary: " << fixed << setprecision(2) << annualSalary;

cout << " Weekly Salary: " << fixed << setprecision(2) << calculatePay();

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 < MIN_WAGE)

this->wage = MIN_WAGE;

else

this->wage = wage;

}

void setHours(double hours)

{

if (hours > MAX_HOURS && hours < MIN_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 < MIN_WAGE)

this->wage = MIN_WAGE;

else

this->wage = wage;

if (hours > MAX_HOURS && hours < MIN_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 < MIN_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 << " Employee Information ";

cout << "________________________________________________________________ ";

cout << " Name: " << firstName << " " << lastName;

cout << " Gender: " << gender;

cout << " Dependents: " << dependents;

cout << " No. Of Hours : " << hours;

cout << " category of Worker: " << category;

cout << " Annual Salary: " << fixed << setprecision(2) << annualSalary;

cout << " Weekly Salary: " << fixed << setprecision(2) << calculatePay();

cout << " ";

benefit.displayBenefits();

}

};

int main()

{

//display banner

cout << "Welcome to your first Object Oriented Program--Employee ClassCIS247C, Week 5 Lab";

cout << "Name: ";

cout << " ******************** Employee 1 ******************** ";

//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 << "Please enter your First Name ";

cin >> fname;

cout << "Please enter your Last Name ";

cin >> lname;

cout << "Please enter your Gender ";

cin >> gender;

cout << "Please enter your Dependents ";

cin >> dependents;

cout << "Please enter your Annual Salary ";

cin >> salstr;

cout << "Please enter your Health insurance ";

cin >> healthins;

cout << "Please enter your life insurance ";

cin >> lifeinsur;

cout << " Please enter your vacation days ";

cin >> vacation;

cout << "Please Enter management Level (0-3)";

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 << "Please enter your First Name ";

cin >> fname;

cout << "Please enter your Last Name ";

cin >> lname;

cout << " Please enter your Gender ";

cin >> gender;

cout << "Please enter your Dependents ";

cin >> dependents;

cout << "Please enter your Annual Salary ";

cin >> sal;

cout << "Please enter your Health insurance ";

cin >> healthins;

cout << "Please enter your life insurance ";

cin >> lifeinsur;

cout << " Please enter your vacation days ";

cin >> vacation;

cout << "Please Enter number of hours (0-50)";

cin >> hours;

cout << "Please Enter Wages Rate ";

cin >> wage;

cout << "Please Enter worker Category(temporary, part time, and full time) ";

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 << " --- Number of Employee Object Created ---- ";

cout << "Number of Employees : " << Employee::getNumEmployees() << " ";

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 << " ******************** Employee 2 ******************** ";

//display employee info

emp2.displayEmployee();

//Calling and displaying number of employee objects created

cout << " --- Number of Employee Object Created ---- ";

cout << "Number of Employees : " << Employee::getNumEmployees() << " ";

cout << " The end of the CIS247C Week5 iLab.";

return 0;

}