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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "Employee.h"
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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "Employee.h"
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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "ProductionWorker.h"
// 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 sh.
This code has nine errors- but I don't know how to solve it- Please g.pdf
1. 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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "Employee.h"
Employee::Employee()
{
2. 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;
}
3. ProductionWorker.h
#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "Employee.h"
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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "ProductionWorker.h"
// 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;
4. 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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "ProductionWorker.h"
using namespace std;
class TeamLeader : public ProductionWorker
{
private:
int monthlyBonus;
int requiredTrainingHours;
int attendedTrainingHours;
public:
TeamLeader();
5. 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 <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "TeamLeader.h"
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)
{
6. attendedTrainingHours = hours;
}
int TeamLeader::getMonthlyBonus() const
{
return monthlyBonus;
}
int TeamLeader::getRequiredTrainingHours() const
{
return requiredTrainingHours;
}
int TeamLeader::getAttendedTrainingHours() const
{
return attendedTrainingHours;
}
Main.cpp
#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include "Employee.h"
#include "ProductionWorker.h"
#include "TeamLeader.h"
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);