14 Replies - 625 Views - Last Post: 25 February 2012 - 09:11 PM Rate Topic: -----

#1 Kaosuvls  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-February 12

Final Project

Posted 23 February 2012 - 08:26 PM

Ok guys I just need a little push on why my program is not doing what I want it to do.

Bare yourself guys, this may be a lot but all the work is done. Im posting the assignment so you guys know what goes where.

Use the following code outline as a starting point for your final project. You will need to correct any errors you find and write code for the missing sections.
#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.
*/

/*
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 = 
*/

/*
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 = 

*/

/*
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 = 

*/

/*
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)] ;
*/

/*
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)]
/*

} //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
*/

/*
Implement function call to output the employee information.  Function is defined below.
*/


	}	// 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
*/

/*
Implement function call to output the employee information.  Function is defined below.
*/

	} // End of the else

} //End of Primary Function

void EmployeeClass::DisplayEmployInformation () {
// 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 ................. = 
*/

} // END OF Display Employee Information

void EmployeeClass::Addsomethingup (EmployeeClass Employ1, EmployeeClass  Employ2){
	// 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.
*/

/*
Then display the information below.  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 576.43
%%%% Total Employee Hours ........ = 108
%%%% Total Overtime Hours......... = 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
	} // End of function







It needs to output something like this:

Welcome to the Employee Pay Center

Enter the employee name = John
Enter the hours worked = 44
Enter his or her hourly wage = 3.33

Enter the employee name = Mary
Enter the hours worked = 33
Enter his or her hourly wage = 2.22

Enter the employee name = Mark
Enter the hours worked = 29
Enter his or her hourly wage = 2.22

Employee Name ............. = John
Base Pay .................. = 133.20
Hours in Overtime ......... = 4
Overtime Pay Amount........ = 19.98
Total Pay ................. = 153.18

Employee Name ............. = Mary
Base Pay .................. = 73.26
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 73.26

Employee Name ............. = Mark
Base Pay .................. = 64.38
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 64.38

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 290.82
%%%% Total Employee Hours ........ = 106
%%%% Total Overtime Hours......... = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


I cannot get it to output the Employee Summary Data properly.
Any suggestion?? The code compiles and runs fine by the way...............


This is my actual code:

#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


Thanks in advance guys for any help....

Is This A Good Question/Topic? 0
  • +

Replies To: Final Project

#2 x68zeppelin80x  Icon User is offline

  • D.I.C Regular

Reputation: 50
  • View blog
  • Posts: 279
  • Joined: 07-March 09

Re: Final Project

Posted 23 February 2012 - 08:42 PM

This is C++ code not Java..?
Was This Post Helpful? 0
  • +
  • -

#3 Kaosuvls  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-February 12

Re: Final Project

Posted 23 February 2012 - 08:55 PM

sorry for that guys
Was This Post Helpful? 0
  • +
  • -

#4 x68zeppelin80x  Icon User is offline

  • D.I.C Regular

Reputation: 50
  • View blog
  • Posts: 279
  • Joined: 07-March 09

Re: Final Project

Posted 23 February 2012 - 09:21 PM

Just wondering, why do you pass the employees name to the calculation function?
void EmployeeClass::ImplementCalculations (string employeeFirstName, string employeeLastName, int hours, float wage)


This is how to clear the screen:
#include <stdlib.h> //Include this header
system("clear");



If everything is public, you should have a struct, not a class

Better overtime calculation:
pay = hours > 40 ? (40 * wage) + ((hours - 40) * (wage * 1.5)) : hours * wage; 



Edit: My pay calculation is a strait-shot answer, here is a better way for your sake.

float wage, hours, overtime_hours, base_pay, overtime_pay, total_pay;
overtime_hours = hours > 40 ? hours - 40 : 0;
hours = hours > 40 ? hours - 40 : hours; // Overwrote hours
base_pay = hours * wage;
overtime_pay = overtime_hours * (wage * 1.5);
total_pay = base_pay + overtime_pay;

This post has been edited by x68zeppelin80x: 23 February 2012 - 10:41 PM

Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg  Icon User is online

  • member icon

Reputation: 3044
  • View blog
  • Posts: 9,280
  • Joined: 25-December 09

Re: Final Project

Posted 23 February 2012 - 09:45 PM

Quote

I cannot get it to output the Employee Summary Data properly.

How do you expect the output to look?
Why are you passing variables into your ImplementCalculations() function? You should be using the values stored in this class instance. When you name your parameters the same as the class variables, you are using the parameters in the calculations, not the class variables. You should not need any of the parameters in this function, you want to use the class member variables in your calculation.

Why are all your data members public. You should think about making the data elements private, and create public member functions to access the data.

Your Addsomethingup() function should not be part of the class since you are accessing three different instances of this class, just make it a global function.


Jim
Was This Post Helpful? 0
  • +
  • -

#6 x68zeppelin80x  Icon User is offline

  • D.I.C Regular

Reputation: 50
  • View blog
  • Posts: 279
  • Joined: 07-March 09

Re: Final Project

Posted 23 February 2012 - 10:28 PM

Why not make an Array of EmployeeClass objects and run a for-loop?
EmployeeClass emp[3];

for (int i = 0; i < 3; i++) {
  cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;

  cout << "Enter employee " << (i+1)<< "'s first name = ";
  cin >> emp[i].employeeFirstName;

  cout << "Enter employee " << (i+1) << "'s last name = ";
  cin >> emp[i].employeeLastName;

  cout << "Enter the hours worked = ";
  cin >> emp[i].hours;

  cout << "Enter employee's hourly wage = ";
  cin >> emp[i].wage;
}


This post has been edited by x68zeppelin80x: 23 February 2012 - 10:29 PM

Was This Post Helpful? 0
  • +
  • -

#7 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1831
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: Final Project

Posted 23 February 2012 - 10:48 PM

View Postjimblumberg, on 23 February 2012 - 11:45 PM, said:

Your Addsomethingup() function should not be part of the class since you are accessing three different instances of this class, just make it a global function.

But according to Post #1 this specification
void EmployeeClass::Addsomethingup (EmployeeClass Employ1, EmployeeClass  Employ2){
	// 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.
*/


was given as part of the OP's assignment so it probably should remain as a member function. The function signature in that stub agrees with the explanation given there.
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5667
  • View blog
  • Posts: 22,509
  • Joined: 23-August 08

Re: Final Project

Posted 24 February 2012 - 03:50 AM

View Postx68zeppelin80x, on 23 February 2012 - 11:21 PM, said:

This is how to clear the screen:
#include <stdlib.h> //Include this header
system("clear");



Only if the system is a non-Windows system.
Was This Post Helpful? 0
  • +
  • -

#9 Kaosuvls  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-February 12

Re: Final Project

Posted 24 February 2012 - 05:19 PM

Ok guys I just need a little push on why my program is not doing what I want it to do.

Bare yourself guys, this may be a lot but all the work is done. Im posting the assignment so you guys know what goes where.

Use the following code outline as a starting point for your final project. You will need to correct any errors you find and write code for the missing sections.

P.S...... I posted this yesterday in the wrong forum......

#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.
*/
 
/*
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 =
*/
 
/*
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 =
 
*/
 
/*
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 =
 
*/
 
/*
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)] ;
*/
 
/*
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)]
/*
 
} //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
*/
 
/*
Implement function call to output the employee information.  Function is defined below.
*/
 
 
    }   // 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
*/
 
/*
Implement function call to output the employee information.  Function is defined below.
*/
 
    } // End of the else
 
} //End of Primary Function
 
void EmployeeClass::DisplayEmployInformation () {
// 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 ................. =
*/
 
} // END OF Display Employee Information
 
void EmployeeClass::Addsomethingup (EmployeeClass Employ1, EmployeeClass  Employ2){
    // 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.
*/
 
/*
Then display the information below. 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 576.43
%%%% Total Employee Hours ........ = 108
%%%% Total Overtime Hours......... = 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
    } // End of function  




It needs to output something like this:

Welcome to the Employee Pay Center

Enter the employee name = John
Enter the hours worked = 44
Enter his or her hourly wage = 3.33

Enter the employee name = Mary
Enter the hours worked = 33
Enter his or her hourly wage = 2.22

Enter the employee name = Mark
Enter the hours worked = 29
Enter his or her hourly wage = 2.22

Employee Name ............. = John
Base Pay .................. = 133.20
Hours in Overtime ......... = 4
Overtime Pay Amount........ = 19.98
Total Pay ................. = 153.18

Employee Name ............. = Mary
Base Pay .................. = 73.26
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 73.26

Employee Name ............. = Mark
Base Pay .................. = 64.38
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 64.38

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 290.82
%%%% Total Employee Hours ........ = 106
%%%% Total Overtime Hours......... = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


I cannot get it to output the Employee Summary Data properly.
Any suggestion?? The code compiles and runs fine by the way...............

This is my actual code:
#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 


Thanks in advance guys for any help....
Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is online

  • member icon

Reputation: 3044
  • View blog
  • Posts: 9,280
  • Joined: 25-December 09

Re: Final Project

Posted 24 February 2012 - 05:30 PM

Please don't open a duplicate topic for the same question.

Topics merged

Quote

I cannot get it to output the Employee Summary Data properly.


What output is your program producing? What do you expect the output to be?

Jim

This post has been edited by jimblumberg: 24 February 2012 - 05:31 PM

Was This Post Helpful? 0
  • +
  • -

#11 Kaosuvls  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-February 12

Re: Final Project

Posted 24 February 2012 - 06:34 PM

It needs to output something like this:

Welcome to the Employee Pay Center

Enter the employee name = John
Enter the hours worked = 44
Enter his or her hourly wage = 3.33

Enter the employee name = Mary
Enter the hours worked = 33
Enter his or her hourly wage = 2.22

Enter the employee name = Mark
Enter the hours worked = 29
Enter his or her hourly wage = 2.22

Employee Name ............. = John
Base Pay .................. = 133.20
Hours in Overtime ......... = 4
Overtime Pay Amount........ = 19.98
Total Pay ................. = 153.18

Employee Name ............. = Mary
Base Pay .................. = 73.26
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 73.26

Employee Name ............. = Mark
Base Pay .................. = 64.38
Hours in Overtime ......... = 0
Overtime Pay Amount........ = 0.00
Total Pay ................. = 64.38

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 290.82
%%%% Total Employee Hours ........ = 106
%%%% Total Overtime Hours......... = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I cannot get it to display the summary part. Everything else is fine
Was This Post Helpful? 0
  • +
  • -

#12 Kaosuvls  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-February 12

Re: Final Project

Posted 24 February 2012 - 07:31 PM

Ok guys I got it to work.

Now I need help with this

o Provide six test plans to verify the logic within the program.
o Plan 1 must display the proper information for employee #1 with overtime pay.
o Plan 2 must display the proper information for employee #1 with no overtime pay.
o Plans 3-6 are duplicates of plan 1 and 2 but for the other employees.

Just an example will do guys.....

Thanks for the input
Was This Post Helpful? 0
  • +
  • -

#13 eker676  Icon User is offline

  • C++ Programmer
  • member icon

Reputation: 318
  • View blog
  • Posts: 1,710
  • Joined: 18-April 09

Re: Final Project

Posted 25 February 2012 - 04:26 PM

This is a final project, you should know how to do this.

Create a few functions and throw them into a test suite class. Then call the functions and verify that the output is correct.
Was This Post Helpful? 1
  • +
  • -

#14 Kaosuvls  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-February 12

Re: Final Project

Posted 25 February 2012 - 07:07 PM

This is my final but we have not went over test cases as of yet so i am lost here a bit guys. I ask the instructor help last week but no response. I just need an example
Was This Post Helpful? 0
  • +
  • -

#15 eker676  Icon User is offline

  • C++ Programmer
  • member icon

Reputation: 318
  • View blog
  • Posts: 1,710
  • Joined: 18-April 09

Re: Final Project

Posted 25 February 2012 - 09:11 PM

Create a class called Tester.
Create a function in that class called test1.

In that function create an employee (I wouldn't get user input, just hard code it)
Then run your implement calculations function.

Make another function called test2 for an employee with overtime.
Repeat as before.

Now to test your class. Just create the Tester and call a few functions. Look at the output and see if it is what it should be.

That may not be the "right" way to create a test suite for a program. I haven't personally created an automated testing class in any of my applications. I usually just run easy test cases and pathological test cases. (Pathological test cases are designed to intentionally break the program).

Once you start making larger programs you would need to automate the entire process for thousands of records but for now that will do.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1