Question
The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has a no-arg constructor (a no-arg contructor is a
The Employee class has three attributes:
private:
string firstName;
string lastName;
string SSN;
The Employee class has
a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use unknown to initialize all private attributes.
a constructor with parameters for each of the attributes
getter and setter methods for each of the private attributes
a method getFullName() that returns the last name, followed by a comma and space, followed by the first name
The Employee class contains information common to all employees; however, we need to store additional information about specific groups of employees, such as hourly workers or salaried workers. For hourly workers, we need to store their hourly rate and the number of hours worked in the past week we also need to calculate their pay for the past week.
Create a subclass HourlyEmployee of Employee
Employee is the superclass
HourlyEmployee is the subclass
The HourlyEmployee has addtional attributes:
private:
float hourlyRate;
int hrsWorked;
The HourlyEmployee class has
a constructor with parameters for each of the attributes (Self-learning: how to call the second constructor defined in the superclass to initialize the private attributes defined in the super class through the constructor of the subclass.)
getter and setter methods for each of the private attributes
a new method used to calculate the weekly salary of an hourly employee. The implementation of this
method is given as follows.
double HourlyEmployee::calcWeeklySalary()
{
double overtime = 0.0;
if (hrsWorked > 40)
{
overtime = (hrsWorked - 40)
* (0.5 * hourlyRate);
}
return overtime + hrsWorked * hourlyRate;
}
Your need to create the Employee class and the HourlyEmployee class as required above to make sure the following given main function will produce the right output.
int main(){
Employee emp1;
cout< cout< Employee emp2("Alice", "Lackey", "291294949"); cout< cout< HourlyEmployee hremp1("Tom", "Steele", "3235245", 7.8, 20); cout< cout< cout< hremp1.setFirstName("Bob"); hremp1.setLastName("Zhang"); hremp1.setSSN("9879870897"); hremp1.setHourlyRate(8.5); hremp1.setHrsWorked(18); cout< } Output: unknown unknown unknown unknown, unknown Alice Lackey 291294949 Lackey, Alice Tom Steele 3235245 7.8 20 Steele, Tom 156 153
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started