Question: C++ I neeed the following added to my existing code: HERE IS THE UML DIAGRAM The only change to the Employee class is that there
C++
I neeed the following added to my existing code:
HERE IS THE UML DIAGRAM

The only change to the Employee class is that there is a new attribute:
+benefit : Benefit
Notice that there is a "+" for this attribute, meaning that it is public. Make sure to examine the multi-arg constructor's signature!
Also, the dotted directed line between Employee and iEmployee specifies that the Employee class must implement the iEmployee abstract class, and thus provide an implementation for the calculatePay method.
1. Using the UML Diagram, create the Benefit class. .
2. Add a Benefit attribute to the Employee class.
3. Initialize the new Benefit attribute in both Employee constructors. Again, take note of the multi-arg constructors parameter list!
4. Create the iEmployee interface (abstract class in C++).
5. Modify the Employee class to implement the new interface so that Employee will have to implement the calculatePay method. 
6. Modify the Employee class to call displayBenefit when displaying Employee information.
Notice that the Employee class now has a public benefit object inside it. This means that you can access the set methods of the Benefit object with the following code:
.benefit.
As an example, to set the lifeInsurance attribute inside an Employee object called emp, we could execute the following code:
emp.benefit.setLifeInsurance(lifeInsurance);
A) Prompt for and set healthInsurance, lifeInsurance, and vacation.
B) Create a Benefit object called benefit1 using the multi-arg construction. Use any information you want for health insurance, life insurance, and vacation.
C) I need to add benefit1 to the Employee object and use the constructor.
"Mary", "Noia", 'F', 5, 24000.0, benefit1
THIS IS WHAT THE OUTPUT SHOULD LOOK LIKE:

THIS IS MY EXISTING CODE THAT NEEDS TO BE UPDATED:
#include
#include
#include
#include
using namespace std;
class Employee
{
protected:
static int numEmployees;
//member variables of Employee class
private:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;
public:
//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)
{
//set the member variables to values passed
firstName = first;
lastName = last;
gender = gen;
dependents = dep;
annualSalary = salary;
//Incrementing number of employees
numEmployees += 1;
}
//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
}
};
int Employee::numEmployees = 0;
int main()
{
//display banner
cout
cout
cout
//declare object for Employee
Employee emp1;
string fname, lname;
string gender, dependents, salstr;
double sal;
//prompt and read employee information
cout
cin >> fname;
cout
cin >> lname;
cout
cin >> gender;
cout
cin >> dependents;
cout
cin >> salstr;
//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
cout
//create second object for Employee
//pass employee information as parameters
Employee emp2 = Employee("Mary", "Noia", 'F', 2, 150000);
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
Get step-by-step solutions from verified subject matter experts
