stuck on my assignment here is what i have so far i need some tips

do not want you to do my asignment just some help thats all

Page 1 of 1

4 Replies - 2187 Views - Last Post: 09 April 2010 - 05:18 AM Rate Topic: -----

#1 summey   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 19-January 09

stuck on my assignment here is what i have so far i need some tips

Posted 08 April 2010 - 07:33 PM

#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 (EmployeeClass Employee0, EmployeeClass Employee1, EmployeeClass Employee2);

	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 Pay 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 his or her 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 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 Employee0, EmployeeClass Employee1, EmployeeClass Employee2)*/
void EmployeeClass::Addsomethingup(){
	// 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.
*/
         



	    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;

		system("PAUSE"); 
		return;

	} // End of function





I used an array and two loops to gather the information and to do the calculations. This was good and this should be how it is in the real world but i am not sure if this will work for this assignment. How would i go about accomplishing the last part? I basically have to take all employees entered and total them.

iTotal_salaries
iTotal_hours
iTotal_overtimeHours


Thank you for your time

Is This A Good Question/Topic? 0
  • +

Replies To: stuck on my assignment here is what i have so far i need some tips

#2 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3825
  • View blog
  • Posts: 13,941
  • Joined: 08-August 08

Re: stuck on my assignment here is what i have so far i need some tips

Posted 08 April 2010 - 07:43 PM

Have you tried something like this?
for (int i = 0; i < numEmployees; ++i ) {
	Employee[i].ImplementCalculations(Employee[i].EmployeeName, Employee[i].hours, Employee[i].wage);
	iTotal_salaries += Employee[i].iIndividualSalary;
	iTotal_hours += Employee[i].hours;
	iTotal_overtimeHours += Employee[i].overtime_hours;
}

Was This Post Helpful? 0
  • +
  • -

#3 summey   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 19-January 09

Re: stuck on my assignment here is what i have so far i need some tips

Posted 08 April 2010 - 08:40 PM

View PostCTphpnwb, on 08 April 2010 - 06:43 PM, said:

Have you tried something like this?
for (int i = 0; i < numEmployees; ++i ) {
	Employee[i].ImplementCalculations(Employee[i].EmployeeName, Employee[i].hours, Employee[i].wage);
	iTotal_salaries += Employee[i].iIndividualSalary;
	iTotal_hours += Employee[i].hours;
	iTotal_overtimeHours += Employee[i].overtime_hours;
}


Thank you for your time !
I was just messing around with the for loop but i was confusing my self. I am just confused on how to pass the data to Addsomethingup function

i got these errors

1>------ Build started: Project: Datamax_Overtime_Pay_Program, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>.\main.cpp(111) : error C2065: 'numEmployees' : undeclared identifier
1>.\main.cpp(112) : error C2065: 'Employee' : undeclared identifier
1>.\main.cpp(112) : error C2228: left of '.ImplementCalculations' must have class/struct/union
1>.\main.cpp(112) : error C2065: 'Employee' : undeclared identifier
1>.\main.cpp(112) : error C2228: left of '.EmployeeName' must have class/struct/union
1>.\main.cpp(112) : error C2065: 'Employee' : undeclared identifier
1>.\main.cpp(112) : error C2228: left of '.hours' must have class/struct/union
1>.\main.cpp(112) : error C2065: 'Employee' : undeclared identifier
1>.\main.cpp(112) : error C2228: left of '.wage' must have class/struct/union
1>.\main.cpp(113) : error C2065: 'Employee' : undeclared identifier
1>.\main.cpp(113) : error C2228: left of '.iIndividualSalary' must have class/struct/union
1>.\main.cpp(114) : error C2065: 'Employee' : undeclared identifier
1>.\main.cpp(114) : error C2228: left of '.hours' must have class/struct/union
1>.\main.cpp(115) : error C2065: 'iTotal_overtimeHours' : undeclared identifier
1>.\main.cpp(115) : error C2065: 'Employee' : undeclared identifier
1>.\main.cpp(115) : error C2228: left of '.overtime_hours' must have class/struct/union
1>Build log was saved at "file://c:\Users\ryan.summey\Documents\Visual Studio 2008\Projects\Datamax_Overtime_Pay_Program\Datamax_Overtime_Pay_Program\Debug\BuildLog.htm"
1>Datamax_Overtime_Pay_Program - 16 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#4 PlasticineGuy   User is offline

  • mov dword[esp+eax],0
  • member icon

Reputation: 281
  • View blog
  • Posts: 1,436
  • Joined: 03-January 10

Re: stuck on my assignment here is what i have so far i need some tips

Posted 09 April 2010 - 01:42 AM

Where did you put that code?
Was This Post Helpful? 0
  • +
  • -

#5 amdcpp   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 20
  • Joined: 06-February 10

Re: stuck on my assignment here is what i have so far i need some tips

Posted 09 April 2010 - 05:18 AM


I would declare the Employee name, hours, and wage as private data
members and make some public methods to set and get the data rather
than having them public and setting them directly:
// Constructor. (Put in public):
EmployeeClass(const string eName, int hours, double salary);

// Implementation in main():
string tempName;    // Temporary storage for name.
int tempHours;      // Temporary storage for hours.
double tempSalary;  // Temporary storage for salary.

cout << "Enter name:";
cin >> tempName;
// ...etc. Input variables to temp.
EmployeeClass person1(tempName, tempHours, tempSalary);   // Create employee with temp variables


And you can keep replacing temp variables with new data for other
employees since we didn't pass them by reference. Const the name
if you don't expect their name to change.

You'll want to make the arguments passed to the
'AddSomethingp' method passed by reference and const so they cannot
be edited or changed in any way:
void Addsomethingup (const EmployeeClass& Employee0, const EmployeeClass& Employee1, const EmployeeClass& Employee2);



However, there is a better way to do this if you know how to overload functions:
// Goes in public part of class:
Employee operator+(const Employee& e1, const Employee& e2) const {
     Employee sum;
     
     sum.iIndividualSalary = e1.iIndividualSalary + e2.iIndividualSalary;
     sum.hours = e1.hours + e2.hours;
     sum.overtime_hours = e1.overtime_hours + e2.overtime_hours;

     return sum;
}


Then you should be able to just do something like this:
total = person1 + person2 + person3;

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1