Question
Write the Program in C++ only Please read the question carefully and only answer whats asked for. Develop an algorithm for processing payroll. The name
Write the Program in C++ only
Please read the question carefully and only answer whats asked for.
Develop an algorithm for processing payroll. The name of the employee, hours worked, and
hourly rate are input. See sample output below for the formatting of the output which includes
the name, the regular pay, overtime pay, deductions, and net pay for the employee. Deductions
are 15% of gross pay. Employees receive regular pay for up to 40 hours of work. Federal law
requires hourly employees be paid time-and-a-half (1.5 times hourly rate) for the hours in excess
of 40 hours in a week. For example, if a persons hourly wage is $8 and he works 60 hours in a
week, his gross pay should be calculated as:
(40 * 8) + (1.5 * 8 * (60 40)) = $560
Write your program using three functions:
getInput uses three reference variables for name, hours worked, hourly rate.
Validate that hours, rate are positive and that name is not blank.
calcPay uses pass by value for hours worked, hourly rate; uses reference variables
for regular pay and overtime pay. Calculates regular pay and overtime
pay.
displayInfo uses pass by value for name, hours worked, hourly rate, regular pay, and
overtime pay. Calculates gross pay, deductions, net pay and displays the
formatted report.
Your main should only have the controlling loop, and calls to the 3 functions.
NOTE: Mixing getline and cin >> can cause an annoying problem.
getline(cin, msg); //will read until there is enter key
//removes the enter key from input stream
cin >> val; //will stop at enter key
//LEAVES the enter key in input stream
//to remove it, use cin.ignore();
You will recognize the problem if you prompt for input, but the program does not stop to allow
you to enter the input. TALK TO ME FOR MORE EXPLANATION.
Sample run: (Test case 1)
Enter the employee's name: John Smith
Enter the number of hours worked this week: 45
Enter the hourly rate: 15.50
Payroll Report for John Smith
==============
Hours Worked: 45
Hourly Rate: 15.50
Regular: 620.00
Overtime: 116.25
Deductions: 110.44
Net Pay: 625.81
Another employee? y
Enter the employee's name: Sue Jones
Enter the number of hours worked this week: 25
Enter the hourly rate: 10
Payroll Report for Sue Jones
==============
Hours Worked: 25
Hourly Rate: 10.00
Regular: 250.00
Overtime: 0.00
Deductions: 37.50
Net Pay: 212.50
Another employee? y
(continue with data below)
Press any key to continue..
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started