Hello I am having trouble calling my addsomethingup() function. It keeps saying too few arguments in the function call. Can anyone let me know what I am doing wrong. I also can only get part of the output to work. I thought it was because of not calling the add fucntion.. Thanks in advance. :) 



#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
using std::cout;

//
//CLASS DECLARATION SECTION
//
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");

    // display welcome information
    cout << "\nWelcome to the Employee Pay Center\n\n";


    /*
    Use this section to define your objects.  You will have one object per employee.  You have only three employees.
    The format is your class name and your object name.
    */

    EmployeeClass Employ1;
    EmployeeClass Employ2;
    EmployeeClass Employ3;

    /*
    Here you will prompt for the first employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Example of Prompts
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    // Enter employees information
    cout << "Enter the first employee's name      = ";
    cin >> Employ1.EmployeeName;

    cout << "\nEnter the hours worked               = ";
    cin >> Employ1.hours;

    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ1.wage;


    /*
    Here you will prompt for the second employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the second employee's name      = ";
    cin >> Employ2.EmployeeName;

    cout << "\nEnter the hours worked                = ";
    cin >> Employ2.hours;

    cout << "\nEnter his or her hourly wage          = ";
    cin >> Employ2.wage;


    /*
    Here you will prompt for the third employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the third employee's name      = ";
    cin >> Employ3.EmployeeName;

    cout << "\nEnter the hours worked               = ";
    cin >> Employ3.hours;

    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ3.wage;


    /*
    Here you will implement a function call to implement the employ calcuations for each object defined above.  You will do this for each of the three employees or objects.
    The format for this step is the following:
    [(object name.function name(objectname.name, objectname.hours, objectname.wage)] ;
    */

    cout << endl;
    Employ1.ImplementCalculations(Employ1.EmployeeName, Employ1.hours, Employ1.wage);
    Employ2.ImplementCalculations(Employ2.EmployeeName, Employ2.hours, Employ2.wage);
    Employ3.ImplementCalculations(Employ3.EmployeeName, Employ3.hours, Employ3.wage);




} // return 0;

/*
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)]
*/

 // END OF Display Employee Information

void EmployeeClass::ImplementCalculations(string EmployeeName, int hours, double wage)
{

    //Initialize overtime variables
    overtime_hours = 0;
    overtime_pay = 0.0;
    overtime_extra = 0.0;


    if (hours > 40)// calculate overtime if hours greater 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();
    }
    // if (hours > 40)
    else
    {

        basepay = hours * wage;
        iIndividualSalary = overtime_pay + 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 Amount ................... " << overtime_hours * overtime_pay << endl;
    cout << "Total Pay ............................. " << iIndividualSalary << endl;


    Addsomethingup();

}// END OF Display Employee Information


void EmployeeClass::Addsomethingup(EmployeeClass Employ1, EmployeeClass Employ2, EmployeeClass Employ3)
    {
        // Adds three 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.
        */
        iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours;
        iTotal_salaries = Employ1.iIndividualSalary + Employ2.iIndividualSalary + Employ3.iIndividualSalary;
        iTotal_OvertimeHours = Employ1.overtime_hours + Employ2.overtime_hours + Employ3.overtime_hours;
        /*
        Then display the information below.
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% Total Employee Salaries ..... = 576.43
        %%%% Total Employee Hours ........ = 108
        %%%% Total Overtime Hours......... = 5
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        */





        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;

        // End of function

    };

I am having trouble with this part of the code.

 Addsomethingup();

}// END OF Display Employee Information
void EmployeeClass::Addsomethingup(EmployeeClass Employ1, EmployeeClass Employ2, EmployeeClass Employ3)
    {
        // Adds three 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.
        */
        iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours;
        iTotal_salaries = Employ1.iIndividualSalary + Employ2.iIndividualSalary + Employ3.iIndividualSalary;
        iTotal_OvertimeHours = Employ1.overtime_hours + Employ2.overtime_hours + Employ3.overtime_hours;
        /*
        Then display the information below.
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% Total Employee Salaries ..... = 576.43
        %%%% Total Employee Hours ........ = 108
        %%%% Total Overtime Hours......... = 5
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        */
        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;
        // End of function
    };

well , i'm also learning about oop concept in c++(please correct me , if i'm wrong).
here you're making a mistake while calling Addsomethingup(); because it requires 3 arguments of EmployeeClass .

you'll get an error even if you pass Employ1,Employ2,Employ3 because you're calling AddSomethingup() in DisplayEmployInformation() that doesn't recognize Employ1,Employ2,Employ3 becuase their scope is limited to main function only.Therefore either declare them as global.

one more problem in your code is that in ImplementCalculations function there is wage variable of type double and you're passing wage parameter which is float. therefore either change float to double or change its datatype in parameter list.

after implementation these little modification , your code looks like this :

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//using std::cout;
//
//CLASS DECLARATION SECTION
//
class EmployeeClass {
public:
        void ImplementCalculations(string EmployeeName, int hours, double wage);
        void DisplayEmployInformation(void);
        void Addsomethingup(EmployeeClass, EmployeeClass, EmployeeClass);
        string EmployeeName;
        int hours;
        double wage;
        float basepay;
        int overtime_hours;
        float overtime_pay;
        float overtime_extra;
        float iTotal_salaries;
        float iIndividualSalary;
        int iTotal_hours;
        int iTotal_OvertimeHours;
};
EmployeeClass Employ1;
    EmployeeClass Employ2;
    EmployeeClass Employ3;
int main()
{
//    system("cls");
    // display welcome information
    cout << "\nWelcome to the Employee Pay Center\n\n";
    /*
    Use this section to define your objects.  You will have one object per employee.  You have only three employees.
    The format is your class name and your object name.
    */

    /*
    Here you will prompt for the first employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Example of Prompts
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    // Enter employees information
    cout << "Enter the first employee's name      = ";
    cin >> Employ1.EmployeeName;
    cout << "\nEnter the hours worked               = ";
    cin >> Employ1.hours;
    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ1.wage;
    /*
    Here you will prompt for the second employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the second employee's name      = ";
    cin >> Employ2.EmployeeName;
    cout << "\nEnter the hours worked                = ";
    cin >> Employ2.hours;
    cout << "\nEnter his or her hourly wage          = ";
    cin >> Employ2.wage;
    /*
    Here you will prompt for the third employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the third employee's name      = ";
    cin >> Employ3.EmployeeName;
    cout << "\nEnter the hours worked               = ";
    cin >> Employ3.hours;
    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ3.wage;
    /*
    Here you will implement a function call to implement the employ calcuations for each object defined above.  You will do this for each of the three employees or objects.
    The format for this step is the following:
    [(object name.function name(objectname.name, objectname.hours, objectname.wage)] ;
    */
    cout << endl;
    Employ1.ImplementCalculations(Employ1.EmployeeName, Employ1.hours, Employ1.wage);
    Employ2.ImplementCalculations(Employ2.EmployeeName, Employ2.hours, Employ2.wage);
    Employ3.ImplementCalculations(Employ3.EmployeeName, Employ3.hours, Employ3.wage);
} // return 0;
/*
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)]
*/
 // END OF Display Employee Information
void EmployeeClass::ImplementCalculations(string EmployeeName, int hours, double wage)
{
    //Initialize overtime variables
    overtime_hours = 0;
    overtime_pay = 0.0;
    overtime_extra = 0.0;
    if (hours > 40)// calculate overtime if hours greater 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();
    }
    // if (hours > 40)
    else
    {
        basepay = hours * wage;
        iIndividualSalary = overtime_pay + 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 Amount ................... " << overtime_hours * overtime_pay << endl;
    cout << "Total Pay ............................. " << iIndividualSalary << endl;
    Addsomethingup(Employ1,Employ2,Employ3);
}// END OF Display Employee Information
void EmployeeClass::Addsomethingup(EmployeeClass Employ1, EmployeeClass Employ2, EmployeeClass Employ3)
    {
        // Adds three 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.
        */
        iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours;
        iTotal_salaries = Employ1.iIndividualSalary + Employ2.iIndividualSalary + Employ3.iIndividualSalary;
        iTotal_OvertimeHours = Employ1.overtime_hours + Employ2.overtime_hours + Employ3.overtime_hours;
        /*
        Then display the information below.
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% Total Employee Salaries ..... = 576.43
        %%%% Total Employee Hours ........ = 108
        %%%% Total Overtime Hours......... = 5
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        */
        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;
        // End of function
    };

Hello and thank you for your help but when I change the members in the function call addsomethingup(Employ1,Employ2,Employ3) I get an error saying that Employ1 ect are undefined... I am not sure what I can do now.

did you make them global ?
then call Addsomethingup(Employ1,Employ2,Employ3); .

did you try the code what i posted ?
that's all what i can do. I don't see any other error.

I did and now it is compiling but not the right way lol.. Here is a sample of the output wanted..

Sample output:

Welcome to the Employee Pay Center

Enter the employee name = John
Enter the hours worked = 44
Enter his or her hourly wage = 3.33

Enter the employee name = Mary
Enter the hours worked = 33
Enter his or her hourly wage = 2.22

Enter the employee name = Mark
Enter the hours worked = 29
Enter his or her hourly wage = 2.22

Employee Name ............. = John
Base Pay .................. = 133.20
Hours in Overtime ......... = 4
Overtime Pay Amount........ = 19.98
Total Pay ................. = 153.18

Employee Name ............. = Mary
Base Pay .................. = 73.26
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 73.26

Employee Name ............. = Mark
Base Pay .................. = 64.38
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 64.38

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 290.82
%%%% Total Employee Hours ........ = 106
%%%% Total Overtime Hours......... = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is the output I am getting now

Welcome to the Employee Pay Center

Enter the first employee's name = John

Enter the hours worked = 44

Enter his or her hourly wage = 3.33

Enter the second employee's name = Mary

Enter the hours worked = 33

Enter his or her hourly wage = 2.22

Enter the third employee's name = Mark

Enter the hours worked = 29

Enter his or her hourly wage = 2.22

Employee Name ......................... John
Base Pay .............................. 133.2
Hours in Overtime ..................... 4
Overtime Pay Amount ................... 19.98
Total Pay ............................. 153.18

%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%

%%%% Total Employee Salaries ........ = 153.18
%%%% Total Employee Hours ........... = 106
%%%% Total Overtime Hours ........... = 4

Employee Name ......................... Mary
Base Pay .............................. 73.26
Hours in Overtime ..................... 0
Overtime Pay Amount ................... 0
Total Pay ............................. 73.26

%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%

%%%% Total Employee Salaries ........ = 226.44
%%%% Total Employee Hours ........... = 106
%%%% Total Overtime Hours ........... = 4

Employee Name ......................... Mark
Base Pay .............................. 64.38
Hours in Overtime ..................... 0
Overtime Pay Amount ................... 0
Total Pay ............................. 64.38

%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%

%%%% Total Employee Salaries ........ = 290.82
%%%% Total Employee Hours ........... = 106
%%%% Total Overtime Hours ........... = 4

Press any key to continue . . .

as i already said that i'm learning oop concept in c++ therefore i couldn't tell the better solution . I think there may exist something by which Addsomethingup is called for once and last only.

So , i can suggest that seperate Addsomethingup from the class and seperate the variables too that this function uses , therefore delcare these variables as global.

anyways , try this for the desired output :

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//using std::cout;
//
//CLASS DECLARATION SECTION
//
class EmployeeClass {
public:
        void ImplementCalculations(string EmployeeName, int hours, double wage);
        void DisplayEmployInformation(void);

        string EmployeeName;
        int hours;
        double wage;
            float basepay;
         int overtime_hours;
         float overtime_pay;
         float overtime_extra;
          float iIndividualSalary;

};
EmployeeClass Employ1;
EmployeeClass Employ2;
EmployeeClass Employ3;
float iTotal_salaries;
int iTotal_hours;
int iTotal_OvertimeHours;
void Addsomethingup(EmployeeClass, EmployeeClass, EmployeeClass);
int main()
{

//    system("cls");
    // display welcome information
    cout << "\nWelcome to the Employee Pay Center\n\n";
    /*
    Use this section to define your objects.  You will have one object per employee.  You have only three employees.
    The format is your class name and your object name.
    */

    /*
    Here you will prompt for the first employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Example of Prompts
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    // Enter employees information
    cout << "Enter the first employee's name      = ";
    cin >> Employ1.EmployeeName;
    cout << "\nEnter the hours worked               = ";
    cin >> Employ1.hours;
    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ1.wage;
    /*
    Here you will prompt for the second employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the second employee's name      = ";
    cin >> Employ2.EmployeeName;
    cout << "\nEnter the hours worked                = ";
    cin >> Employ2.hours;
    cout << "\nEnter his or her hourly wage          = ";
    cin >> Employ2.wage;
    /*
    Here you will prompt for the third employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the third employee's name      = ";
    cin >> Employ3.EmployeeName;
    cout << "\nEnter the hours worked               = ";
    cin >> Employ3.hours;
    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ3.wage;
    /*
    Here you will implement a function call to implement the employ calcuations for each object defined above.  You will do this for each of the three employees or objects.
    The format for this step is the following:
    [(object name.function name(objectname.name, objectname.hours, objectname.wage)] ;
    */
    cout << endl;
    Employ1.ImplementCalculations(Employ1.EmployeeName, Employ1.hours, Employ1.wage);
    Employ2.ImplementCalculations(Employ2.EmployeeName, Employ2.hours, Employ2.wage);
    Employ3.ImplementCalculations(Employ3.EmployeeName, Employ3.hours, Employ3.wage);

    Addsomethingup(Employ1,Employ2,Employ3);
} // return 0;
/*
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)]
*/
 // END OF Display Employee Information
void EmployeeClass::ImplementCalculations(string EmployeeName, int hours, double wage)
{
    //Initialize overtime variables
    overtime_hours = 0;
    overtime_pay = 0.0;
    overtime_extra = 0.0;
    if (hours > 40)// calculate overtime if hours greater 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();
    }
    // if (hours > 40)
    else
    {
        basepay = hours * wage;
        iIndividualSalary = overtime_pay + 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 Amount ................... " << overtime_hours * overtime_pay << endl;
    cout << "Total Pay ............................. " << iIndividualSalary << endl;

}// END OF Display Employee Information
void Addsomethingup(EmployeeClass Employ1, EmployeeClass Employ2, EmployeeClass Employ3)
    {
        // Adds three 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.
        */
        iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours;
        iTotal_salaries = Employ1.iIndividualSalary + Employ2.iIndividualSalary + Employ3.iIndividualSalary;
        iTotal_OvertimeHours = Employ1.overtime_hours + Employ2.overtime_hours + Employ3.overtime_hours;
        /*
        Then display the information below.
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% Total Employee Salaries ..... = 576.43
        %%%% Total Employee Hours ........ = 108
        %%%% Total Overtime Hours......... = 5
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        */
        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;
        // End of function
    };

hope somebody could give suggestion so that the output can be obtained without making the variable global and without sperating the function from the class.

Thank you very much for the help :). Now if there is anyone out there that can do as suggested above please help me. Thanks

Please if there is someone out there that can help me figure out how to get the desired output.

just try the code which i put in my last post. it'll produce the desired output.
yeah , you can ask for better solution.

Thank you hun :). Can you explain why we did that? I am confused.

you can try this too :

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//using std::cout;
//
//CLASS DECLARATION SECTION
//
class EmployeeClass {
public:
        void ImplementCalculations(string EmployeeName, int hours, double wage);
        void DisplayEmployInformation(void);

        string EmployeeName;
        int hours;
        double wage;
        float iTotal_salaries;
        int iTotal_hours;
        int iTotal_OvertimeHours;
        float basepay;
        int overtime_hours;
        float overtime_pay;
        float overtime_extra;
        float iIndividualSalary;
        friend void Addsomethingup(EmployeeClass, EmployeeClass, EmployeeClass);

};
EmployeeClass Employ1;
EmployeeClass Employ2;
EmployeeClass Employ3;


int main()
{

//    system("cls");
    // display welcome information
    cout << "\nWelcome to the Employee Pay Center\n\n";
    /*
    Use this section to define your objects.  You will have one object per employee.  You have only three employees.
    The format is your class name and your object name.
    */

    /*
    Here you will prompt for the first employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Example of Prompts
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    // Enter employees information
    cout << "Enter the first employee's name      = ";
    cin >> Employ1.EmployeeName;
    cout << "\nEnter the hours worked               = ";
    cin >> Employ1.hours;
    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ1.wage;
    /*
    Here you will prompt for the second employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the second employee's name      = ";
    cin >> Employ2.EmployeeName;
    cout << "\nEnter the hours worked                = ";
    cin >> Employ2.hours;
    cout << "\nEnter his or her hourly wage          = ";
    cin >> Employ2.wage;
    /*
    Here you will prompt for the third employee’s information.
    Prompt the employee name, hours worked, and the hourly wage.  For each piece of information, you will update the appropriate class member defined above.
    Enter the employee name      =
    Enter the hours worked       =
    Enter his or her hourly wage =
    */
    cout << "\nEnter the third employee's name      = ";
    cin >> Employ3.EmployeeName;
    cout << "\nEnter the hours worked               = ";
    cin >> Employ3.hours;
    cout << "\nEnter his or her hourly wage         = ";
    cin >> Employ3.wage;
    /*
    Here you will implement a function call to implement the employ calcuations for each object defined above.  You will do this for each of the three employees or objects.
    The format for this step is the following:
    [(object name.function name(objectname.name, objectname.hours, objectname.wage)] ;
    */
    cout << endl;
    Employ1.ImplementCalculations(Employ1.EmployeeName, Employ1.hours, Employ1.wage);
    Employ2.ImplementCalculations(Employ2.EmployeeName, Employ2.hours, Employ2.wage);
    Employ3.ImplementCalculations(Employ3.EmployeeName, Employ3.hours, Employ3.wage);

    Addsomethingup(Employ1,Employ2,Employ3);
    return 0;
} // return 0;
/*
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)]
*/
 // END OF Display Employee Information
void EmployeeClass::ImplementCalculations(string EmployeeName, int hours, double wage)
{
    //Initialize overtime variables
    overtime_hours = 0;
    overtime_pay = 0.0;
    overtime_extra = 0.0;
    if (hours > 40)// calculate overtime if hours greater 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();
    }
    // if (hours > 40)
    else
    {
        basepay = hours * wage;
        iIndividualSalary = overtime_pay + 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 Amount ................... " << overtime_hours * overtime_pay << endl;
    cout << "Total Pay ............................. " << iIndividualSalary << endl;

}// END OF Display Employee Information
void Addsomethingup(EmployeeClass Employ1, EmployeeClass Employ2, EmployeeClass Employ3)
    {
        // Adds three 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.
        */
        EmployeeClass ob;
        ob.iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours;
        ob.iTotal_salaries = Employ1.iIndividualSalary + Employ2.iIndividualSalary + Employ3.iIndividualSalary;
        ob.iTotal_OvertimeHours = Employ1.overtime_hours + Employ2.overtime_hours + Employ3.overtime_hours;
        /*
        Then display the information below.
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%% Total Employee Salaries ..... = 576.43
        %%%% Total Employee Hours ........ = 108
        %%%% Total Overtime Hours......... = 5
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        */
        cout << endl;
        cout << "%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%" << endl;
        cout << endl;
        cout << "%%%% Total Employee Salaries ........ = " << ob.iTotal_salaries << endl;
        cout << "%%%% Total Employee Hours ........... = " << ob.iTotal_hours << endl;
        cout << "%%%% Total Overtime Hours ........... = " << ob.iTotal_OvertimeHours << endl;
        cout << endl;
        // End of function
    };

Thank you very much for your help :)!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.