Oct 10, 2013 at 6:34pm UTC
I am really new to the C++ programming. I have a code that was done but for some reason I cant get the code to produce the final employee data results. What am I doing wrong? Can someone please help me with this? Thanks in advance.
#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