#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.
*/
EmployeeClass EmployeeClass1;
EmployeeClass EmployeeClass2;
EmployeeClass EmployeeClass3;
/*
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 =
*/
cout << "\n\nEnter the first employee name: ";
cin >> EmployeeClass1.EmployeeName ;
cout << "Enter the hours worked: ";
cin >> EmployeeClass1.hours;
cout << "Enter his or her hourly wage: ";
cin >> EmployeeClass1.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 << "\n\nEnter the second employee name: ";
cin >> EmployeeClass2.EmployeeName ;
cout << "Enter the hours worked: ";
cin >> EmployeeClass2.hours;
cout << "Enter his or her hourly wage: ";
cin >> EmployeeClass2.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 << "\n\nEnter the third employee name: ";
cin >> EmployeeClass3.EmployeeName ;
cout << "Enter the hours worked: ";
cin >> EmployeeClass3.hours;
cout << "Enter his or her hourly wage: ";
cin >> EmployeeClass3.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)] ;
*/
EmployeeClass1.ImplementCalculations(EmployeeClass1.EmployeeName, EmployeeClass1.hours, EmployeeClass1.wage) ;
EmployeeClass2.ImplementCalculations(EmployeeClass2.EmployeeName, EmployeeClass2.hours, EmployeeClass2.wage) ;
EmployeeClass3.ImplementCalculations(EmployeeClass3.EmployeeName, EmployeeClass3.hours, EmployeeClass3.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)]
*/ EmployeeClass TotalEmploy;
[TotalEmploy.Addsomethingup(EmployeeClass1, EmployeeClass2, EmployeeClass3)]
} //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
*/
basepay=40*wage;
overtime_hours=hours-40;
overtime_pay=wage*1.5;
overtime_extra=overtime_hours*overtime_pay;
iIndividualSalary=overtime_extra+basepay;
/*
Implement function call to output the employee information. Function is defined below.
*/
void EmployeeClass::DisplayEmployInformation ()
} // 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
*/
basepay=hours*wage;
iIndividualSalary=basepay;
/*
Implement function call to output the employee information. Function is defined below.
*/
void EmployeeClass::DisplayEmployInformation ()
} // End of the else
} //End of Primary Function
{
// 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 ................. =
*/
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 EmployeeClass1, EmployeeClass EmployeeClass2){
// 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.
*/
iTotal_salaries = 0;
iTotal_hours = 0;
iTotal_OvertimeHours = 0;
/*
Then display the information below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 576.43
%%%% Total Employee Hours ........ = 108
%%%% Total Overtime Hours......... = 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
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
haroldelam 0 Newbie Poster
haroldelam 0 Newbie Poster
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.