hi all
i need to write a program that calculates and prints payslips. User inputs are the names of the employees, the number of hours worked and the pay rate. i have to declare three functions
a) one for input:
b) one to calculate the employees pay;
c) one to print the pay slip.
The input function has to input the name of the employee, the number of hours worked and the hourly pay rate into the variables theEmployee, theHoursWorked and thePayRate. the variable 'employee' is a string and the other two are floats. as the values of the three variable numbers will be changed preference parameters need to be used.
The calculation function will receive two parameters that represent the number of hours worked and the hourly pay rate, do the calculation and return the pay for the employee. An employee, who has worked more than 40 hours, is paid 1.5 times the hourly rate for each hour of overtime. As the parameters are not changed in the function they should be value parameters. The function should return a float value which represents the pay.
the output function has to display the name of the employee, the number of hours worked, the number of overtime hours and the hourly pay rate entered by the user as well as the employees pay. eg
Pay slip for Harry Matsipe
Hours worked: 43.5 hours
Overtime hours: 3.5
Hourly pay rate: R125.35
Pay: R5672.09
The main function includes a for loop that allows the user to repeat the calculation of a pay slip for five employees.
*******************************************************************************
I have managed to complete some code but i am now very stuck and battling. Please can someone help me with the rest of the code for this problem
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <iostream>
#include <string>
using namespace std;
//declare function for the input
void theEmployee (string & employee)
{
cout << "Enter the employees name: " << endl;
cin >> employee;
}
void theHoursWorked (float & hoursworked)
{
cout << "Enter the number of hours worked: " << endl;
cin >> hoursworked;
}
void thePayRate (float & payRate)
{
cout << "Enter the pay rate for the employee: " << endl;
cin >> payRate;
}
//Declare function for the calculation
void thePay ( float pay, float payRate, float hoursworked)
{
cout << "The pay for the employee is: " << endl;
pay = payRate * hoursworked;
}
{
if ( hoursworked > 40 )
{
overTimePay = ((hoursworked - 40) * (payRate * 1.5) + ( 40 * payRate ) )
}
else
{
overTime = 0
}
}
int main()
{
for ( i = 5)
}
|