The program runs but I can not get it to add the totals from the three employess. Then when i enter an employee info the totals show after each employee instead of the end. Please help. If you can please explain what I need to do in simple terms. Its my first class and I do not have it down yet, thank you.
#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 Addsomethingup (void);
string EmployeeName ;
int hours ;
double wage ;
double basepay ;
double overtime_hours ;
double overtime_pay ;
double overtime_extra ;
double iTotal_salaries ;
double iIndividualSalary ;
int iTotal_hours ;
int iTotal_OvertimeHours ;
};
int main()
{ system("cls");
cout << "\nWelcome to the Employee Pay Center\n\n" ;
EmployeeClass Employee [3];
const int numEmployees = sizeof (Employee) / sizeof (Employee [0]);
for (int i = 0; i < numEmployees; ++i)
{
cout<<"\n\n Enter your employee name: ";
cin >> Employee[i].EmployeeName;
cout << "Enter hours worked: ";
cin >> Employee[i].hours;
cout << "Enter your hourly wage: ";
cin >> Employee[i].wage;
}
for (int i = 0; i < numEmployees; ++i )
{
Employee[i].ImplementCalculations(Employee[i].EmployeeName,Employee[i].hours, Employee[i].wage);
}
}
void EmployeeClass::ImplementCalculations (string EmployeeName, int hours, double wage)
//Initialize overtime variables
{
basepay=0.0;
overtime_hours=0;
overtime_pay=0.0;
overtime_extra=0.0;
iIndividualSalary=0.0;
if (hours > 40)// more than 40
{
basepay = (40 * wage);
overtime_hours = hours-40;
overtime_pay = wage * 1.5;
overtime_extra = overtime_hours*overtime_pay;
iIndividualSalary = (overtime_extra + basepay);
DisplayEmployInformation();
}
else // less than 40 hours
{
basepay=hours*wage;
iIndividualSalary=basepay;
DisplayEmployInformation();
}
} //End of Main Function
void EmployeeClass::DisplayEmployInformation ()
{
// This function displays all the employee output information.
cout<<"n\n";
cout<<"Employee Name ...................=" << EmployeeName << endl;
cout<<"Base Pay ....................=" << basepay << endl;
cout<<"Hours in Overtime ....................=" << overtime_hours << endl;
cout<<"Overtime Pay ....................=" << overtime_extra << endl;
cout<<"Total Pay ....................=" << iIndividualSalary << endl;
Addsomethingup();
} // END OF Display Employee Information
void EmployeeClass::Addsomethingup ()
{
iTotal_salaries=0;
iTotal_hours=0;
iTotal_OvertimeHours=0;
{
}
cout << "\n\n";
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
cout << "%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%" << endl;
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
cout << "%%%% Total Employee Salaries ..... =" << iTotal_salaries << endl;
cout << "%%%% Total Employee Hours ........ =" << iTotal_hours << endl;
cout << "%%%% Total Overtime Hours......... =" << iTotal_OvertimeHours << endl;
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
system("Pause");
} // End of function