Question
This code has nine errors, but I don't know how to solve it. Please give me a code that resolves all errors and executes well.
This code has nine errors, but I don't know how to solve it.
Please give me a code that resolves all errors and executes well. Please provide the code for each file name.
( Employee.h, Employee.cpp, ProductionWorker.h, ProductionWorker.cpp, TeamLeader.h, TeamLeader.cpp, Main.cpp)
Employee.h
#include
using namespace std;
class Employee { private: string employeeName; string employeeNumber; string hireDate;
public: Employee(); // default constructor Employee(string name, string number, string date); // constructor with parameters void setEmployeeName(string employeeName); // set employee name void setEmployeeNumber(string employeeNumber); // set employee number void setHireDate(string hireDate); // set hire date string getEmployeeName() const; // get employee name string getEmployeeNumber() const; // get employee number string getHireDate() const; // get hire date };
Employee.cpp
#include
Employee::Employee() { cout << "Please answer some questions about your employees. " << endl; }
// Constructor with parameters Employee::Employee(string name, string number, string date) { employeeName = name; employeeNumber = number; hireDate = date; }
// Set employee name void Employee::setEmployeeName(string name) { employeeName = name; }
// Set employee number void Employee::setEmployeeNumber(string number) { employeeNumber = number; }
// Set hire date void Employee::setHireDate(string date) { hireDate = date; }
// Get employee name string Employee::getEmployeeName() const { return employeeName; }
// Get employee number string Employee::getEmployeeNumber() const { return employeeNumber; }
// Get hire date string Employee::getHireDate() const { return hireDate; }
ProductionWorker.h
#include
#include
using namespace std;
class ProductionWorker : public Employee { private: int shift; int hourlyPay;
public: ProductionWorker(); // default constructor ProductionWorker(string name, string number, string date, int s, int pay); // constructor with parameters void setShift(int shift); // set shift void setHourlyPay(int pay); // set hourly pay int getShift() const; // get shift int getHourlyPay() const; // get hourly pay };
ProductionWorker.cpp
#include
// Default constructor ProductionWorker::ProductionWorker() { cout << "Your responses will be displayed after all data has been received." << endl; }
// Constructor with parameters ProductionWorker::ProductionWorker(string name, string number, string date, int s, int pay) : Employee(name, number, date) { shift = s; hourlyPay = pay; }
// Set shift void ProductionWorker::setShift(int s) { shift = s; }
// Set hourly pay void ProductionWorker::setHourlyPay(int pay) { hourlyPay = pay; }
// Get shift int ProductionWorker::getShift() const { return shift; }
// Get hourly pay int ProductionWorker::getHourlyPay() const { return hourlyPay; }
TeamLeader.h
#include
using namespace std;
class TeamLeader : public ProductionWorker { private: int monthlyBonus; int requiredTrainingHours; int attendedTrainingHours;
public: TeamLeader(); TeamLeader(string name, string number, string date, int s, int pay, int bonus, int reqTrainingHours, int attTrainingHours); void setMonthlyBonus(int bonus); void setRequiredTrainingHours(int hours); void setAttendedTrainingHours(int hours); int getMonthlyBonus() const; int getRequiredTrainingHours() const; int getAttendedTrainingHours() const; };
TeamLeader.cpp
#include
#include
TeamLeader::TeamLeader() { cout << "Your responses will be displayed after all data has been received." << endl; }
TeamLeader::TeamLeader(string name, string number, string date, int s, int pay, int bonus, int reqTrainingHours, int attTrainingHours) : ProductionWorker(name, number, date, s, pay) { monthlyBonus = bonus; requiredTrainingHours = reqTrainingHours; attendedTrainingHours = attTrainingHours; }
void TeamLeader::setMonthlyBonus(int bonus) { monthlyBonus = bonus; }
void TeamLeader::setRequiredTrainingHours(int hours) { requiredTrainingHours = hours; }
void TeamLeader::setAttendedTrainingHours(int hours) {
attendedTrainingHours = hours; }
int TeamLeader::getMonthlyBonus() const { return monthlyBonus; }
int TeamLeader::getRequiredTrainingHours() const { return requiredTrainingHours; }
int TeamLeader::getAttendedTrainingHours() const { return attendedTrainingHours; }
Main.cpp
#include
#include
using namespace std;
int main() { string name, number, date; int shift, requiredTrainingHours, attendedTrainingHours; int hourlyPay, monthlyBonus;
// Get employee information cout << "Enter employee name: "; getline(cin, name);
cout << "Enter employee ID: "; getline(cin, number);
cout << "Enter hire date: "; getline(cin, date);
cout << "Enter shift (1 for day, 2 for night): "; cin >> shift;
cout << "Enter pay rate: "; cin >> hourlyPay;
cout << "Enter bonus rate: "; cin >> monthlyBonus;
cout << "Enter training hours: "; cin >> attendedTrainingHours;
cout << "Enter required hours: "; cin >> requiredTrainingHours;
// Create team leader object TeamLeader tl(name, number, date, shift, hourlyPay, monthlyBonus, requiredTrainingHours, attendedTrainingHours);
// Display employee and production worker information cout << "===================================" << endl; cout << "The employee name : " << tl.getEmployeeName() << endl; cout << fixed << setprecision(2) << "The Pay Rate : " << tl.getHourlyPay() << endl; cout << "The employee ID : " << tl.getEmployeeNumber() << endl; cout << "The Hire Date : " << tl.getHireDate() << endl; cout << "Shift : " << (tl.getShift() == 1 ? "Day" : "Night") << endl;
// Display team leader information cout << fixed << setprecision(2) << "Bonus Rate : " << tl.getMonthlyBonus() << endl; cout << "Training hours : " << tl.getAttendedTrainingHours() << endl; cout << "Required hours : " << tl.getRequiredTrainingHours() << endl;
return 0; }
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