here is the code that I have. I'm supposed to be able to input 3 employees, display their individual totals and also combined totals. I know there's some error with the functions or adding, because my result is:
Employee Name ......................... mary
Base Pay .............................. 200
Hours in Overtime ..................... 3
Overtime Pay Amount ................... 22.5
Total Pay ............................. 222.5
%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ........ = -9.25596e+061
%%%% Total Employee Hours ........... = -9.25596e+061
%%%% Total Overtime Hours ........... = -9.25596e+061
Employee Name ......................... jack
Base Pay .............................. 280
Hours in Overtime ..................... 6
Overtime Pay Amount ................... 63
Total Pay ............................. 343
%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ........ = -9.25596e+061
%%%% Total Employee Hours ........... = -9.25596e+061
%%%% Total Overtime Hours ........... = -9.25596e+061
Employee Name ......................... ken
Base Pay .............................. 320
Hours in Overtime ..................... 8
Overtime Pay Amount ................... 96
Total Pay ............................. 416
%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ........ = -9.25596e+061
%%%% Total Employee Hours ........... = -9.25596e+061
%%%% Total Overtime Hours ........... = -9.25596e+061
Press any key to continue .
Please tell me where I need to adjust. I have tried adding and changing things and then I receive compiler errors. With the current code I receive no errors, just not the desired outcome either.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
// //CLASS DECLARATION SECTION //
class EmployeeClass {
public:
void ImplementCalculations(string EmployeeName, int hours, double wage);
void DisplayEmployInformation(void);
void DisplayTotals(void);
void Addsomethingup (EmployeeClass, EmployeeClass, EmployeeClass);
string EmployeeName ;
double hours ;
double wage ;
double basepay ;
double overtime_hours ;
double overtime_pay ;
double overtime_extra ;
double iTotal_salaries ;
double iIndividualSalary ;
double iTotal_hours ;
double iTotal_OvertimeHours ;
};
int main()
{ system("cls");
cout << "\nWelcome to the Employee Pay Center\n\n" ;
EmployeeClass Emp1;
EmployeeClass Emp2;
EmployeeClass Emp3;
cout << "Enter the first employee's name = ";
cin >> Emp1.EmployeeName;
system("cls");
cout << "\nEnter the hours worked = ";
cin >> Emp1.hours;
system("cls");
cout << "\nEnter his or her hourly wage = ";
cin >> Emp1.wage;
system("cls");
cout << "Enter the next employee's name = ";
cin >> Emp2.EmployeeName;
system("cls");
cout << "\nEnter the hours worked = ";
cin >> Emp2.hours;
system("cls");
cout << "\nEnter his or her hourly wage = ";
cin >> Emp2.wage;
system("cls");
cout << "Enter the next employee's name = ";
cin >> Emp3.EmployeeName;
system("cls");
cout << "\nEnter the hours worked = ";
cin >> Emp3.hours;
system("cls");
cout << "\nEnter his or her hourly wage = ";
cin >> Emp3.wage;
system("cls");
cout << endl;
Emp1.ImplementCalculations(Emp1.EmployeeName, Emp1.hours, Emp1.wage);
Emp2.ImplementCalculations(Emp2.EmployeeName, Emp2.hours, Emp2.wage);
Emp3.ImplementCalculations(Emp3.EmployeeName, Emp3.hours, Emp3.wage);
/*
This section you will send all three objects to a function that will add up the the following information:
Total Employee Salaries
Total Employee Hours
Total Overtime Hours
/*The format for this function is the following:
Define a new object.
Implement function call [objectname.functionname(object name 1, object name 2, object name 3)]
*/
system ("pause");
return 0;
} //End of Main Function
void EmployeeClass::ImplementCalculations (string EmployeeName, int hours, double wage){
//*Initialize overtime variables*//
overtime_hours=0;
overtime_pay=0;
overtime_extra=0;
if (hours > 40)
{
basepay = 40 * wage;
overtime_hours = hours - 40;
overtime_pay = wage * 1.5;
overtime_extra = overtime_hours * overtime_pay;
iIndividualSalary = overtime_extra + basepay;
} // if (hours > 40)
else
{
basepay = hours * wage;
iIndividualSalary = basepay;
} // End of the else
DisplayEmployInformation();
void addsomethingup ();
DisplayTotals();
} //End of Primary Function
void EmployeeClass::DisplayEmployInformation () {
// This function displays all the employee output information.
cout << "Employee Name ......................... " << setw(15) << EmployeeName <<endl;
cout << "Base Pay .............................. " << setw(15) << basepay << endl;
cout << "Hours in Overtime ..................... " << setw(15) << overtime_hours << endl;
cout << "Overtime Pay Amount ................... " << setw(15) << overtime_extra << endl;
cout << "Total Pay ............................. " << setw(15) << iIndividualSalary << endl << endl;
} // END OF Display Employee Information
void EmployeeClass::Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3){
// Adds two objects of class Employee passed as
// function arguments and saves them as the calling object's data member values.
iTotal_salaries = Emp1.iIndividualSalary + Emp2.iIndividualSalary + Emp3.iIndividualSalary;
iTotal_hours = Emp1.hours + Emp2.hours + Emp3.hours;
iTotal_OvertimeHours = Emp1.overtime_hours + Emp2.overtime_hours + Emp3.overtime_hours;
}
void EmployeeClass::DisplayTotals () {
cout << "%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%" << endl;
cout << "%%%% Total Employee Salaries ........ = " << iTotal_salaries << endl;
cout << "%%%% Total Employee Hours ........... = " << iTotal_hours << endl;
cout << "%%%% Total Overtime Hours ........... = " << iTotal_OvertimeHours << endl;
} // End of function