// 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.
}
triumphost 120 Posting Whiz
Wow... 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 off its bad practice to do #include ... inside the main function.. why would u also put using namespace std inside the main function?
Secondly you cannot declare a function inside of another one.. If you need to do this, do:
void myfunction(); //<--- this is declaring the function as a function-prototype..
int main() //Secondly I noticed u had int main(); ... you cannot do that. u have to remove the semi-colon.
{
}
void myfunction()
{
//Do stuff here
}
"highlight" is an undeclared variable which you have called before declaring it.
Also your missing the <<higlight<< ... you were missing the << operands...
For this line:
cout << "%%%% Total <strong class="<<highlight<<">Overtime</strong> Hours......... =" << iTotal_OvertimeHours << endl;
numEmployees is also undeclared..
Another << missing from the highlight code.
cout << "<strong class="highlight">Overtime</strong> <strong class="highlight">Pay</strong> Amout......... = " << overtime_extra << endl;
should be
cout << "<strong class="<<highlight<<">Overtime</strong> <strong class="highlight">Pay</strong> Amout......... = " << overtime_extra << endl;
You have a LOT! of brackets missing you did not close the class with a } bracket before the };
Why is your class declared IN main??
anyway this is as far as I can help you... other errors u WILL fix yourself.. I cant go through every single one.. I've done 99% of them.. All u have to do is declare the highlight variable AND call the functions as prototypes or however but U CANNOT declare a function inside another one..
// Finals.cpp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#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);
}
return 0;
}
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");
}
Edited by triumphost because: n/a
Ancient Dragon commented: very helpful +36
smitty34 -3 Newbie Poster
Thank you for the help
smitty34 -3 Newbie Poster
// Finals.cpp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#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);
}
return 0;
}
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 << "integral"; ++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;
}
This is the result of the build with error messages:
------ Build started: Project: Finals.cpp, Configuration: Debug Win32 ------
Build started 4/2/2011 1:14:41 PM.
InitializeBuildStatus:
Touching "Debug\Finals.cpp.unsuccessfulbuild".
ClCompile:
All outputs are up-to-date.
Finals.cpp.cpp
c:\documents and settings\rad trans\my documents\visual studio 2010\projects\finals.cpp\finals.cpp\finals.cpp.cpp(114): error C2297: '<<' : illegal, right operand has type 'const char [9]'
c:\documents and settings\rad trans\my documents\visual studio 2010\projects\finals.cpp\finals.cpp\finals.cpp.cpp(127): fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\rad trans\my documents\visual studio 2010\projects\finals.cpp\finals.cpp\finals.cpp.cpp(107)' was matched
Build FAILED.
Time Elapsed 00:00:01.39
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
triumphost 120 Posting Whiz
You 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 as a string? U dont have to put << you can just do:
cout << "%%%% Total <strong class=highlight>Overtime</strong> Hours......... =" << iTotal_OvertimeHours << endl;
This is because that entire part of the line is a string..
You CANNOT do: for (int i = 0; i << "integral"; ++i ) That is the error it is telling you about Const char[9]
You are declaring i as an integer which is equal to 0 and then telling it that while i is less than a string do the following and then increase i for everytime it loops through..
That is impossible. For an integer to be less than a string..
Not exactly sure how many times you want to loop through that procedure but you can do this:
for (int i = 0; i < 10; ++i ) //<--- Notice that now its the correct syntax stating that while I is less than 10, do...
//or u can do
for (int i = 0; i < n; ++i ) //<--- where "n" is an integer that has a value >= 0.
Edited by triumphost because: n/a
smitty34 -3 Newbie Poster
You are awesome thank you so much for the help!!!
sergent 52 Posting Pro
I tried to fix it but you have some wierd "highlight" with a wrong cout operator.
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.