// Finals.cpp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
#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 <strong class="highlight">Pay</strong> 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 employee 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 <strong class="highlight">Pay</strong> .................. = " << basepay << endl;
cout << "Hours in <strong class="highlight">Overtime</strong> ......... = " << overtime_hours << endl;
cout << "<strong class="highlight">Overtime</strong> <strong class="highlight">Pay</strong> Amout......... = " << overtime_extra << endl;
cout << "Total <strong class="highlight">Pay</strong> ................. = " << 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 <strong class="highlight">Overtime</strong> Hours......... =" << iTotal_OvertimeHours << endl;
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
system("PAUSE");
return;
}
return 0;//This is the main return of the program.
}
smitty34 -3
Newbie Poster
Recommended Answers
Jump to PostWow... I dont mean to criticize but damn!! u have so many errors.. I suggest reading a tutorial on function-prototypes, classes and functions.. And maybe some syntax's. I tried to compile, I fixed quite a lot but there is no way in hell am I gunna fix all..
First …
Jump to PostYou are missing a bracket for void EmployeeClass::Addsomethingup()
Add a } at the end of the code above.. should be line 127.
as for this:
cout << "%%%% Total <strong class="<<"highlight"<<">Overtime</strong> Hours......... ="
Not sure why you did that.. You see where it shows highlight …
All 6 Replies
triumphost 120
Posting Whiz
Ancient Dragon
commented:
very helpful +36
smitty34 -3
Newbie Poster
smitty34 -3
Newbie Poster
triumphost 120
Posting Whiz
smitty34 -3
Newbie Poster
sergent 52
Posting Pro
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.