View the step-by-step solution to:

#include <iostream> #include <string> #include "Employee.h" #include "Hourly.h" #include "Salary.h"...

#include <iostream>
#include <string>
#include "Employee.h"
#include "Hourly.h"
#include "Salary.h"
#include "Manager.h"

using namespace std;

void printEmployee(Employee * emp)
{
	cout << "Employee info" << endl;
	cout << emp->toString();

	cout << "Employee pay: $" << emp->calculatePay() << endl;

	Manager * mgr = dynamic_cast<Manager*>(emp);
	if (mgr != NULL)
	{
		cout << "Bonus: $" << mgr->getBonus() << endl;
	}
	cout << endl << endl;

}

int main()
{
	Hourly firstEmployee("John", "Smith", "123-45-6789", "888-888-8888", 30, 27);
	Salary secondEmployee("Henry", "Jones", "711-50-7589", "999-999-999", 50000);
	Manager thirdEmployee("Edward", "Johnson", "931-45-9010", "555-555-555", 50000, 5000);

	cout << "Size of first object: " << sizeof(firstEmployee) << endl;
	cout << "Size of first object pointer: " << sizeof(&firstEmployee) << endl;
	
	printEmployee(&firstEmployee);
	printEmployee(&secondEmployee);
	printEmployee(&thirdEmployee);
	
	cout << endl;
	system("pause");

	return 0;
}

#pragma once
#include <string>
#include <sstream>
#include <iomanip>
#include "Salary.h"

using namespace std;

class Manager : public Salary
{
private:

	double bonus;

public:

	float calculatePay();
	string toString();
	double getBonus();
	Manager(string fname, string lname, string ssn, string phone, double annualSalary, double bonus);
};

#include "Manager.h"


float Manager::calculatePay() 
{
	return (Salary::annualSalary + bonus) / 52.0;
}

string Manager::toString()
{
	stringstream output;
	output << Salary::toString();
	output << fixed << setprecision(2);
	output << "Total Weekly Pay With Bonus: $" << calculatePay() << endl;
	output << "Bonus: $" << bonus << endl;
	return output.str();
}

double Manager::getBonus()
{
	return bonus;
}
Manager::Manager(string fname, string lname, string ssn, string phone, double annualSalary, double bonus) : Salary(fname, lname, ssn, phone, annualSalary)
{
	this->bonus = bonus;
}

#pragma once
#include <sstream>
#include <string>

using namespace std;
class Employee
{
     protected:

		 string fname;
		 string lname;
		 string ssn;
		 string phone;

     public:

		 virtual float calculatePay() = 0;
		 virtual string toString();
		 Employee(string fname, string lname, string ssn, string phone);
	     
};

#include "Employee.h"

float Employee::calculatePay()
{
	return 0.0;
}

string Employee::toString()
{
	stringstream output;
	output << "Employee name: " << fname << " " << lname << endl;
	output << "Employee's SSN: " << ssn << endl;
	output << "Employee's Phone Number: " << phone << endl;
	return output.str();
}
Employee::Employee(string fname, string lname, string ssn, string phone)
{
	this->fname = fname;
	this->lname = lname;
	this->ssn = ssn;
	this->phone = phone;
}

#pragma once
#include <string>
#include <sstream>
#include <iomanip>
#include "Employee.h"

using namespace std;

class Hourly : public Employee
{
    private:

		float rate;
		float hours;

    public:

		float calculatePay();
		string toString();
		Hourly(string fname, string lname, string ssn, string phone, float rate, float hours);
	    
};

#include "Hourly.h"


float Hourly::calculatePay() 
{
	return hours * rate;
}

string Hourly::toString()
{
	stringstream output;
	output << Employee::toString();
	output << fixed << setprecision(2);
	output << "Total Amount Payed: $" << hours * rate << endl;
	return output.str();
}

Hourly::Hourly(string fname, string lname, string ssn, string phone, float rate, float hours) : Employee(fname, lname, ssn, phone)
{
	this->rate = rate;
	this->hours = hours;
}

#pragma once
#include <string>
#include <sstream>
#include <iomanip>
#include "Employee.h"

using namespace std;

class Salary : public Employee
{
    protected:

		double annualSalary;


    public:

		float calculatePay();
		string toString();
		Salary(string fname, string lname, string ssn, string phone, double annualSalary);
	    
};

#include "Salary.h"


float Salary::calculatePay()
{
	return annualSalary / 52.0;
}

string Salary::toString()
{
	stringstream output;
	output << Employee::toString();
	output << fixed << setprecision(2);
	output << "Total Weekly Pay: $" << annualSalary / 52.0 << endl;
	output << "Total Annual Salary:"<< annualSalary << endl;
	return output.str();
}

Salary::Salary(string fname, string lname, string ssn, string phone, double annualSalary) : Employee(fname, lname, ssn, phone)
{

}


Help me fix my code and please stop reporting me. I only need help fixing this issue. thank you.

run01.PNG

run01.PNG

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question