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

I need to have employee 2 display benefit information like employee 1 so far I h

ID: 3805092 • Letter: I

Question

I need to have employee 2 display benefit information like employee 1 so far I have:

#include
#include
#include
using namespace std;

class Employee
{
private:

//Private members of class Employee

string firstName;
string lastName;
string gender;
int dependents;
double salary;
static int numEmployees;

public:

//Public member funtions of class Employee

//Default constructor

Employee()

{

firstName="Not Given";
lastName="Not Given";
gender="U";
dependents=0;
salary=20000;
numEmployees +=1;

}

//parameterised constructor

Employee(string firstName,string lastName,string gender,int dependents,double salary)

{

numEmployees +=1;

this->firstName =firstName;

this->lastName =lastName;

this->gender =gender;

this->dependents =dependents;

this->salary =salary;

}

//Method to prompt the user to enter Employee data

void getData()

{

cout<<"Please enter your first name: ";

cin>>firstName;

setFirstName(firstName);

cout<<"Please enter your last name: ";

cin>>lastName;

setLastName(lastName);

cout<<"Please enter your gender: ";

cin>>gender;

setGender(gender);

cout<<"Please enter your dependents: ";

cin>>dependents;

setDependents(dependents);

cout<<"Please enter your salary: ";

cin>>salary;

setAnnualSalary(salary);

}

//setter methods

void setFirstName(string firstName)

{

this->firstName=firstName;

}

void setLastName(string lastName)

{

this->lastName =lastName;

}

void setGender(string gender)

{

this->gender =gender;

}

void setDependents(int dependents)

{

this->dependents =dependents;

}

void setAnnualSalary(double salary)

{

this->salary =salary;

}

//getter methods

string getFirstName()

{

return firstName;

}

string getLastName()

{

return lastName;

}

string getGender()

{

return gender;

}

int getDependents()

{

return dependents;

}

double getAnnualSalary()
{

return salary;

}

//To calculate

double calculatePay()
{

return getAnnualSalary()/52;

}

void display()
{

cout<<" Employee Information ";
cout<<"________________________________________________________________ ";
cout<<" Name: "<

}

static int getNumEmployees()
{
return numEmployees;
}
};

int Employee::numEmployees=0;

class Benefit:public Employee
{
private:
string healthInsurance;
double lifeInsurance;
double vacation;
public:
Benefit()
{
this->healthInsurance="";
this->lifeInsurance=0;
this->vacation=0;
}

Benefit(string hi,double li, double vac)
{
this->healthInsurance=hi;
this->lifeInsurance=li;
this->vacation=vac;
}

string getHealthInsurance()
{
return this->healthInsurance;
}

double getLifeInsurance()
{
return this->lifeInsurance;
}

double getVacation()
{
return this->vacation;
}

void setHealthInsurance(string hi)
{
this->healthInsurance=hi;
}

void setLifeInsurance(double li)
{
this->lifeInsurance=li;
}

void setVacation(double v)
{
this->vacation=v;
}
};

int main()
{

string hi;
double li;
double vac;
//display banner
cout<<"Welcome this program is for CIS247C, Week 4 iLab"< cout<<"Name: Jose Gongora"< cout<<" ******************** Employee 1 ******************** ";
//Prompt user to enter Employee data

Benefit obj;
//calling getData method


obj.getData();

cout<<"Enter the Health Insurance:";
cin>>hi;

cout<<"Enter the Life Insurance:";
cin>>li;

cout<<"Enter the Vacation:";
cin>>vac;

obj.setHealthInsurance(hi);
obj.setLifeInsurance(li);
obj.setVacation(vac);

obj.display ();

cout<<"Benefit Information"< cout<<"-----------------------------"< cout<<"Health Insurance: "< cout<<"Life Insurance: "< cout<<"Vacation: "< //Creating parameterised constructor
cout<<" ******************** Employee 2 ******************** ";
Employee obj2("Mary", "Noia", "F", 5, 24000.0);
obj2.display();
system("pause");
}

Output must look like:

CAWINDOWSAsystem321cmd.exe NCIS247CWeek4iLab CMD. EXE was started with the above path as the current directory. UNC paths are not supported Defaulting to Windows directory lelcome to your object oriented Program--Enployee ClassCIS247C, Week 4 LabNane Nana Liu Employee 1 Please enter your First Nane Nana Please enter your Last Nane Liu Please enter your Gender Fenale Please enter your Dependents 2 Please enter your Annual Salary 60000 Please enter your Health InsuranceCigna Please enter your Life Insuarance1.5 Please enter your .Uocation Days21 Employee Information Nane Nana Liu Gender Dependents: Annual Salary 60000.00 Weekly Salary: 1153.85 Benefit Information Health Insurance Cigna Life Insurance: 1.50 Vacation 21 days Number of Employee 0bject Created Nunber of employees 1 Employee 2 Employee Information Mary Noia Nane Gender Dependents: Annual Salary 150000.00 Weekly Salary: 2884.62 Benefit Information Health Insurance: North West Mutual 5000000.00 Life Insurance Vacation 14 days Nunber of Employee object Created Number of employees: 2 The end of the CI Week4 iLab. Press any key to continue

Explanation / Answer

HI, I have modified your program according to your requirement.

Please let me know in case of any issue.

#include <iostream>
#include <string>
using namespace std;
class Employee
{
private:
//Private members of class Employee
string firstName;
string lastName;
string gender;
int dependents;
double salary;
static int numEmployees;
public:
//Public member funtions of class Employee
//Default constructor
Employee()
{
firstName="Not Given";
lastName="Not Given";
gender="U";
dependents=0;
salary=20000;
numEmployees +=1;
}
//parameterised constructor
Employee(string firstName,string lastName,string gender,int dependents,double salary)
{
numEmployees +=1;
this->firstName =firstName;
this->lastName =lastName;
this->gender =gender;
this->dependents =dependents;
this->salary =salary;
}
//Method to prompt the user to enter Employee data
void getData()
{
cout<<"Please enter your first name: ";
cin>>firstName;
setFirstName(firstName);
cout<<"Please enter your last name: ";
cin>>lastName;
setLastName(lastName);
cout<<"Please enter your gender: ";
cin>>gender;
setGender(gender);
cout<<"Please enter your dependents: ";
cin>>dependents;
setDependents(dependents);
cout<<"Please enter your salary: ";
cin>>salary;
setAnnualSalary(salary);
}
//setter methods
void setFirstName(string firstName)
{
this->firstName=firstName;
}
void setLastName(string lastName)
{
this->lastName =lastName;
}
void setGender(string gender)
{
this->gender =gender;
}
void setDependents(int dependents)
{
this->dependents =dependents;
}
void setAnnualSalary(double salary)
{
this->salary =salary;
}
//getter methods
string getFirstName()
{
return firstName;
}
string getLastName()
{
return lastName;
}
string getGender()
{
return gender;
}
int getDependents()
{
return dependents;
}
double getAnnualSalary()
{
return salary;
}
//To calculate
double calculatePay()
{
return getAnnualSalary()/52;
}
void display()
{
cout<<" Employee Information ";
cout<<"________________________________________________________________ ";
cout<<" Name: "<<firstName<<" "<<lastName<<endl;
cout<<"Gender: "<<gender<<endl;
cout<<"Dependents: "<<dependents<<endl;
cout<<"Annual Salary: "<<salary<<endl;
cout<<"Weekly Salary: "<<calculatePay()<<endl;
}
static int getNumEmployees()
{
return numEmployees;
}
};
int Employee::numEmployees=0;
class Benefit:public Employee
{
private:
string healthInsurance;
double lifeInsurance;
double vacation;
public:
Benefit()
{
this->healthInsurance="";
this->lifeInsurance=0;
this->vacation=0;
}
Benefit(string hi,double li, double vac)
{
this->healthInsurance=hi;
this->lifeInsurance=li;
this->vacation=vac;
}
string getHealthInsurance()
{
return this->healthInsurance;
}
double getLifeInsurance()
{
return this->lifeInsurance;
}
double getVacation()
{
return this->vacation;
}
void setHealthInsurance(string hi)
{
this->healthInsurance=hi;
}
void setLifeInsurance(double li)
{
this->lifeInsurance=li;
}
void setVacation(double v)
{
this->vacation=v;
}
};
int main()
{
string hi;
double li;
double vac;
//display banner
cout<<"Welcome this program is for CIS247C, Week 4 iLab"<<endl;
cout<<"Name: Jose Gongora"<<endl;
cout<<" ******************** Employee 1 ******************** ";
//Prompt user to enter Employee data
Benefit obj;
//calling getData method

obj.getData();
cout<<"Enter the Health Insurance:";
cin>>hi;
cout<<"Enter the Life Insurance:";
cin>>li;
cout<<"Enter the Vacation:";
cin>>vac;
obj.setHealthInsurance(hi);
obj.setLifeInsurance(li);
obj.setVacation(vac);
obj.display ();
cout<<"Benefit Information"<<endl;
cout<<"-----------------------------"<<endl;
cout<<"Health Insurance: "<<obj.getHealthInsurance()<<endl;
cout<<"Life Insurance: "<<obj.getLifeInsurance()<<endl;
cout<<"Vacation: "<<obj.getVacation()<<endl;
//Creating parameterised constructor
cout<<" ******************** Employee 2 ******************** ";
Benefit obj2("Caig",5, 24000.0);
obj2.setFirstName("Mary");
obj2.setLastName("Noia");
obj2.setGender("F");
obj2.display();
cout<<"Benefit Information"<<endl;
cout<<"-----------------------------"<<endl;
cout<<"Health Insurance: "<<obj2.getHealthInsurance()<<endl;
cout<<"Life Insurance: "<<obj2.getLifeInsurance()<<endl;
cout<<"Vacation: "<<obj2.getVacation()<<endl;

//system("pause");
}