#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 (EmployeeClass Employee0, EmployeeClass Employee1, EmployeeClass Employee2);
string EmployeeName;
int hours , overtime_hours, iTotal_hours, iTotal_OvertimeHours;
double wage, basepay;
double overtime_pay, overtime_extra;
double iTotal_salaries, iIndividualSalary;
};
int main()
{
cout << "\nDatamax, Inc - Welcome to the Employee Pay Center\n\n";
// I utilized an array and two loops.
EmployeeClass Employee[3];
const int numEmployees = sizeof(Employee) / sizeof(Employee[0]);
for (int i = 0; i < numEmployees; ++i )
{
cout << "\n\nEnter the employee name = ";
cin >> Employee[i].EmployeeName;
cout << "Enter the hours worked = ";
cin >> Employee[i].hours;
cout << "Enter his or her 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){
basepay = 0.0;
overtime_hours = 0;
overtime_pay = 0.0;
overtime_extra = 0.0;
iIndividualSalary = 0.0;
if (hours > 40)//More than 40 hours
{
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 Primary 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 Amout......... = " << overtime_extra << endl;
cout << "Total Pay ................. = " << iIndividualSalary << endl;
} // END OF Display Employee Information
/*void EmployeeClass::Addsomethingup (EmployeeClass Employee0, EmployeeClass Employee1, EmployeeClass Employee2)*/
void EmployeeClass::Addsomethingup(){
// Adds two objects of class Employee passed as
// function arguments and saves them as the calling object's data member values.
/*
Add the total hours for objects 1, 2, and 3.
Add the salaries for each object.
Add the total overtime hours.
*/
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");
return;
} // End of function
I used an array and two loops to gather the information and to do the calculations. This was good and this should be how it is in the real world but i am not sure if this will work for this assignment. How would i go about accomplishing the last part? I basically have to take all employees entered and total them.
iTotal_salaries
iTotal_hours
iTotal_overtimeHours
Thank you for your time

New Topic/Question
Reply



MultiQuote






|