I was able to get everything to work howeverthe last part should print like below. Can anyone please give me some idea of what I am missing? Thanks..
Output missing:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 290.82
%%%% Total Employee Hours ........ = 106
%%%% Total Overtime Hours......... = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Here is my program. I believe the issue is only with the final part.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class EmployeeClass
{
public:
void ImplementCalculations(string EmployeeName, int hours, double wage);
void DisplayEmployInformation(void);
void Addsomethingup (EmployeeClass, EmployeeClass, EmployeeClass);
string EmployeeName ;
int hours ;
float wage ;
float basepay ;
int overtime_hours ;
float overtime_pay ;
float overtime_extra ;
float iTotal_salaries ;
float iIndividualSalary ;
int iTotal_hours ;
int 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 Second 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 Third 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);
cin.get();
return 0;
}
void EmployeeClass::ImplementCalculations (string EmployeeName, int hours, double wage){
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;
DisplayEmployInformation();
}
else
{
basepay = 40 * wage;
overtime_hours = 0;
overtime_pay = 0;
overtime_extra = 0;
iIndividualSalary = overtime_extra + basepay;
}
DisplayEmployInformation();
}
void EmployeeClass::DisplayEmployInformation () {
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;
}
void EmployeeClass::Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3){
iTotal_hours = Emp1.hours + Emp2.hours + Emp3.hours;
iTotal_salaries = Emp1.iIndividualSalary + Emp2.iIndividualSalary + Emp3.iIndividualSalary;
iTotal_OvertimeHours = Emp1.overtime_hours + Emp2.overtime_hours + Emp3.overtime_hours;
for(int i=0; i<55; i++)
cout << "%";
cout << endl;
cout << "%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%" << endl;
for(int i=0; i<55; i++)
cout << "%";
cout << endl;
cout << "%%%% Total Employee Salaries ........ = " << setw(15) << iTotal_salaries << endl;
cout << "%%%% Total Employee Hours ........... = " << setw(15) <<iTotal_hours << endl;
cout << "%%%% Total Overtime Hours ........... = " << setw(15) <<iTotal_OvertimeHours << endl;
for(int i=0; i<55; i++)
cout << "%";
cout << endl;
for(int i=0; i<55; i++)
cout << "%";
cout << endl;
}
Please use codetags ( <> button ).
I think u didnt call the void Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3)
inside the main. isnt it?