Overtime Pay Program

Ok guys I just need a little push on why my program is not doing what I want it to do.

Bare yourself guys, this may be a lot but all the work is done. Im posting the assignment so you guys know what goes where.

Use the following code outline as a starting point for your final project. You will need to correct any errors you find and write code for the missing sections.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <iostream>
#include <string>
#include <iomanip>
     
using namespace std;
 
//
//CLASS DECLARATION SECTION
//
class EmployeeClass {
public:
    void ImplementCalculations(string EmployeeName, double 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" ;
 
/*
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 =
*/
 
/*
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 =
 
*/
 
/*
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 =
 
*/
 
/*
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)] ;
*/
 
/*
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 Main Function
 
 
void EmployeeClass::ImplementCalculations (string EmployeeName, double hours, double wage){
//Initialize overtime variables
overtime_hours=0;
overtime_pay=0;
overtime_extra=0;
 
    if (hours > 40)
    {      
 
/*
This section is for the basic calculations for calculating overtime pay.
-   base pay = 40 hours times the hourly wage
-   overtime hours = hours worked – 40
-   overtime pay = hourly wage * 1.5
-   overtime extra pay over 40 = overtime hours * overtime pay
-   salary = overtime money over 40 hours + your base pay
*/
 
/*
Implement function call to output the employee information.  Function is defined below.
*/
 
 
    }   // if (hours > 40)
    else
    {  
 
/* Here you are going to calculate the hours less than 40 hours.
-   Your base pay is = your hours worked times your wage
-   Salary = your base pay
*/
 
/*
Implement function call to output the employee information.  Function is defined below.
*/
 
    } // End of the else
 
} //End of Primary Function
 
void EmployeeClass::DisplayEmployInformation () {
// This function displays all the employee output information.
 
/*
This is your cout statements to display the employee information:
Employee Name ............. =
Base Pay .................. =
Hours in Overtime ......... =
Overtime Pay Amount........ =
Total Pay ................. =
*/
 
} // END OF Display Employee Information
 
void EmployeeClass::Addsomethingup (EmployeeClass Employ1, EmployeeClass  Employ2){
    // 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.
*/
 
/*
Then display the information below. 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 576.43
%%%% Total Employee Hours ........ = 108
%%%% Total Overtime Hours......... = 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
    } // End of function  


It needs to output something like this:

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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


I cannot get it to output the Employee Summary Data properly.
Any suggestion?? The code compiles and runs fine by the way...............



This is my actual code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <iostream>
#include <string>
#include <iomanip>
      
using namespace std;
      
 
 
class EmployeeClass {
public:
    void ImplementCalculations(string employeeFirstName, string employeeLastName, int hours, float wage);
    void DisplayEmployInformation(void);
    void Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3);
    string employeeFirstName, employeeLastName;
    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 Data Max Inc. Employee Pay Center\n\n" ;
      
 
EmployeeClass Emp1;
EmployeeClass Emp2;
EmployeeClass Emp3;
 
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
  
    cout << "\n\nEnter the first employee's first name = ";
    cin >> Emp1.employeeFirstName;
 
    cout << "\n\nEnter the first employee's last name = ";
    cin >> Emp1.employeeLastName;
     
    cout << "\n\nEnter the hours worked = ";
    cin >> Emp1.hours;
     
    cout << "\n\nEnter employee's hourly wage = ";
    cin >> Emp1.wage;
     
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
 
    cout << "\n\nEnter the second employee's first name = ";
    cin >> Emp2.employeeFirstName;
 
    cout << "\n\nEnter the second employee's last name = ";
    cin >> Emp2.employeeLastName;
     
    cout << "\n\nEnter the hours worked = ";
    cin >> Emp2.hours;
     
    cout << "\n\nEnter employee's hourly wage = ";
    cin >> Emp2.wage;
     
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
 
    cout << "\n\nEnter the third employee's first name = ";
    cin >> Emp3.employeeFirstName;
 
    cout << "\n\nEnter the third employee's last name = ";
    cin >> Emp3.employeeLastName;
     
    cout << "\n\nEnter the hours worked = ";
    cin >> Emp3.hours;
     
    cout << "\n\nEnter employee's hourly wage = ";
    cin >> Emp3.wage;
     
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
    cout << endl;
 
    Emp1.ImplementCalculations(Emp1.employeeFirstName, Emp1.employeeLastName, Emp1.hours, Emp1.wage);
    Emp2.ImplementCalculations(Emp2.employeeFirstName, Emp2.employeeLastName, Emp2.hours, Emp2.wage);
    Emp3.ImplementCalculations(Emp3.employeeFirstName, Emp3.employeeLastName, Emp3.hours, Emp3.wage);
 
     
  
cin.get();
    cin.get();
        return 0;   
      
} //End of Main Function
      
      
void EmployeeClass::ImplementCalculations (string employeeFirstName, string employeeLastName, int hours, float wage){
//Initialize overtime variables
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();
  
    }   // if (hours > 40)
    else
    { 
    basepay = hours * wage;
    iIndividualSalary = basepay;
          
          
    } // End of the else
          
    DisplayEmployInformation();
      
          
} //End of Primary Function
      
void EmployeeClass::DisplayEmployInformation () {
    // This function displays all the employee output information.
      
 
      
    cout << "\n\n";
    cout << "Employee First Name ............. = " << employeeFirstName << endl;
    cout << "Employee Last Name .............. = " << employeeLastName << 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 Emp1, EmployeeClass Emp2, EmployeeClass Emp3){
 
    iTotal_salaries = 0;
    iTotal_hours = 0;
    iTotal_OvertimeHours = 0;
     
         
    iTotal_hours = Emp1.hours + Emp2.hours + Emp3.hours;
    iTotal_salaries = iIndividualSalary + iIndividualSalary + iIndividualSalary;
    iTotal_OvertimeHours = overtime_hours + overtime_hours + 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;
 
} // End of function 

Thanks in advance guys for any help....
1
2
3
    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;


You need to make sure that when adding up salaries and overtime hours, you add together each of the variables from each element of the class. What you're currently doing is adding up the same variable 3 times.

You also need to call the function somewwhere in the main
Last edited on
thanks for the help
Still cannot get it to even show the Summary however
Last edited on
You also need to call the function somewhere in the main



1
2
3
4
5
int main()
//...
EmployeeClass Emp4;
Emp4.Addsomethingup(Emp1,Emp2,Emp3);
//... 
Last edited on
ok guys, this is the part im stuck on:

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

I think I am messing up in this area because I a not sure what to put here. Any help would be great.

All I can think of is to put:

int Addsomethingup();

or should it be something like:
1
2
EmployeeClass Addsomethingup
Addsomethingup.Addsomethingup(Emp1,Emp2,Emp3)
Last edited on
figured it out guys.
Now I need help with this

o Provide six test plans to verify the logic within the program.
o Plan 1 must display the proper information for employee #1 with overtime pay.
o Plan 2 must display the proper information for employee #1 with no overtime pay.
o Plans 3-6 are duplicates of plan 1 and 2 but for the other employees.

I do not know where to start putting the code at.

Just an example will do guys.....

Thanks for the input
Topic archived. No new replies allowed.