C++ Groupe Projet (Mahsa) 2022

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

/**********************************************************************************

Program Name : Salary calculator (over time pay)

Language Used : C++

**********************************************************************************
*/

#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

//

//CLASS DECLARATION SECTION

//

class EmployeeClass

public:

void ImplementCalculations(string EmployeefirstName,string EmployeelastName, int hours,


double wage);

void DisplayEmployInformation(void);

void Addsomethingup (EmployeeClass, EmployeeClass, EmployeeClass);

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()

cout << "\n%%%%%%%%%%%% Welcome to MAHSA Employee Over_time Pay Center %%%%%
%%%%%%%\n\n" ;

/*

We Use this section to define your objects. we will have one object per employee. we have only
three employees.

The format is your class name and your object name.

*/

EmployeeClass Emp1;

EmployeeClass Emp2;

EmployeeClass Emp3;

/*

Here we will prompt for the first employee's information.

Prompt the employee name, hours worked, and the hourly wage. For each piece of information,
we 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 =

*/

cout << "Enter the first employee First Name:";

cin >> Emp1.EmployeefirstName;

cout<< "Enter the first employee Last Name:";


cin>> Emp1.EmployeelastName;

cout << "\nEnter the hours worked: ";

cin >> Emp1.hours;

cout << "\nEnter his or her hourly wage:";

cin >> Emp1.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:

*/

cout << "Enter the next employee First name:\n";

cin >> Emp2.EmployeefirstName;

cout<< "Enter the next Employee Last Name:\n";

cin>> Emp2.EmployeelastName;

cout << "\nEnter the hours worked: ";

cin >> Emp2.hours;

cout << "\nEnter his or her hourly wage:";

cin >> Emp2.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:

*/

cout << "Enter the next employee First name:\n";

cin >> Emp3.EmployeefirstName;

cout<< "Enter the next employee Last Name\n";

cin>> Emp3.EmployeelastName;

cout << "\nEnter the hours worked:";

cin >> Emp3.hours;

cout << "\nEnter his or her hourly wage:";

cin >> Emp3.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)] ;

*/

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);

/*

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

*/

EmployeeClass temp;

temp.Addsomethingup(Emp1,Emp2,Emp3);

return 0;

} //End of Main Function

void EmployeeClass::ImplementCalculations (string EmployeefirstName,string EmployeelastName,


int 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

*/

basepay = 40 * wage;
overtime_hours = hours - 40;

overtime_pay = wage * 1.5;

overtime_extra = overtime_hours * overtime_pay;

iIndividualSalary = overtime_extra + basepay;

/*

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

*/

DisplayEmployInformation();

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

*/

basepay = hours * wage;

iIndividualSalary = basepay;

/*

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

*/

DisplayEmployInformation();

} // 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 ................. =

*/

cout << "Employee Name .......... = " << EmployeefirstName << " "<< EmployeelastName << endl;

cout << "Base Pay .................. = " << setprecision(5)<<"RM"<< basepay << endl;

cout << "Hours in Overtime ......... = " << setprecision(4)<<"RM"<< overtime_hours << endl;

cout << "Overtime Pay Amount........ = " << setprecision(5)<<"RM"<< overtime_pay << endl;

cout << "Total Pay ................. = " << setprecision(5)<<"RM"<< iIndividualSalary << endl;

} // END OF Display Employee Information

void EmployeeClass::Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2,


EmployeeClass Emp3)

// 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.

*/

iTotal_hours = Emp1.hours + Emp2.hours + Emp3.hours;

iTotal_salaries = Emp1.iIndividualSalary + Emp2.iIndividualSalary + Emp3.iIndividualSalary;


iTotal_OvertimeHours = Emp1.overtime_hours + Emp2.overtime_hours + Emp3.overtime_hours;

//Then display the information below.//_

cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"


<< endl;

cout << "%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%" << endl;

cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" <<


endl;

cout << "%%%% Total Employee Salaries ..... = " << setprecision(6)<<iTotal_salaries <<endl;

cout << "%%%% Total Employee Hours ........ = " << setprecision(5)<<iTotal_hours << endl;

cout << "%%%% Total Overtime Hours......... = " << setprecision(5)<<iTotal_OvertimeHours << endl;

cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" <<


endl;

cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" <<


endl;

} // End of function

This is the output

%%%%%%%%%%%% Welcome to MAHSA Employee Over_time Pay Center %%%%%%%%%%%%

Enter the first employee First Name:SIDIKI

Enter the first employee Last Name:DOUMBOUYA

Enter the hours worked: 65

Enter his or her hourly wage:45

Enter the next employee First name: FADOUMOU

Enter the next Employee Last Name: HASSAN


Enter the hours worked: 65

Enter his or her hourly wage:45

Enter the next employee First name:

HUSSEIN

Enter the next employee Last Name

ABDIRAHMAN

Enter the hours worked:64

Enter his or her hourly wage:34

Employee Name .......... = SIDIKI DOUMBOUYA

Base Pay .................. = RM1800

Hours in Overtime ......... = RM25

Overtime Pay Amount........ = RM67.5

Total Pay ................. = RM3487.5

Employee Name .......... = FADOUMOU HASSAN

Base Pay .................. = RM1800

Hours in Overtime ......... = RM25

Overtime Pay Amount........ = RM67.5

Total Pay ................. = RM3487.5

Employee Name .......... = HUSSEIN ABDIRAHMAN

Base Pay .................. = RM1360

Hours in Overtime ......... = RM24

Overtime Pay Amount........ = RM51

Total Pay ................. = RM2584

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% Total Employee Salaries ..... = 9559

%%%% Total Employee Hours ........ = 194

%%%% Total Overtime Hours......... = 74

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Process returned 0 (0x0) execution time : 63.150 s

Press any key to continue.

You might also like