#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 , 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;
 
	   Addsomethingup(); 

} // END OF Display Employee Information



   void EmployeeClass::Addsomethingup (){ 

   iTotal_salaries = 0;
   iTotal_hours = 0;
   iTotal_OvertimeHours = 0;

	    
	  for (int i = 0; i < numEmployees; ++i ) 


	    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
I initialized these in the Addsomethingup function and started to make a for loop but im not clear on how to pass the data from that aray at the top to Addsomthingup function do that calculations

iTotal_salaries
iTotal_hours
iTotal_overtimeHours


Thank you for your time

Send it to the function by sending the array as a reference or a pointer. Google Function parameters for more inforation

This article has been dead for over six months. Start a new discussion instead.