Need a program based on the following question: A bookstore owner wants you to w
ID: 3644905 • Letter: N
Question
Need a program based on the following question:A bookstore owner wants you to write a program to calculate the store's weekly payroll. The store's employees are paid hourly. Overtime is to be paid at the rate of 1.5 times the normal rate for hours an employee worked over 40. The program should prompt the user to enter the number of hours the employee worked and the pay rate for the employee. The program should display the regular pay, overtime pay, and gross pay for that employee. Then the program should prompt the user to enter the data for another employee. When the user responds that there are no more employees to process, the program should display the number of employees it processed and the total payroll, that is, the sum of the gross salaries of the employees.
The program should validate the pay rate as it is entered. The only valid hourly pay rates are the following: 5.50, 6.00, 6.50, 6.75, 7.00, 7.25, 7.50, 7.75, 8.00. Store the rates in an array. When a pay rate is entered, search the array for a match. If there is a match, continue the rest of the calculations. If there is no match, display an error message, a list of the valid pay rates, and prompt for another pay rate.
Explanation / Answer
#include // for keyboard/screen I/O #include // for file I/O using namespace std; void CalcPay ( float, float, float& ); const float MAX_HOURS = 40.0; // Maximum normal hours const float OVERTIME = 1.5; // Overtime pay factor int main( ) { float payRate; // Employee’s pay rate float hourswork; // Hours worked float wages; // Wages earned float total; // Total company payroll int empNum; // Employee ID number int trnnum; // Employee TRN number int category; ofstream payFile; // Company payroll file payFile.open( “payfile.dat” ); // Open file total = 0.0; // Initialize total cout > empNum; // Read ID number while ( empNum != 0 ) // While not done { cout > payRate; // Read pay rate cout > hourswork; // and hours worked cout > "trnnumber"; cout > "category"; If (hoursworked > 40) && (pay rate > 200) then Print input data Print appropriate message Salary not calculated Else If( category = = “programmer”) “Prompt user for schedule time” If schedule time = = yes Bonus = 5000 Weeklypay = bonus + (hoursworked * hourlyrate) Else Weeklypay = hoursworked *hourlyrate print (payslip) weeklypay , input data ElseIf (category = =”sales rep”) Prompt user to enter weekly sales If (weeklysales > 20000) Commission = 2000 Weeklypay = commission + (hourlyrate * hoursworked) print (payslip) weeklypay , input data Else If (weeklysales > = 10000) && (weekly sales < = 20000) Commission = 1000 Weeklypay = commission + (hoursworked + hourlyrate) print (payslip) weeklypay , input data Endif Else If (hours worked > 30) then Overtime = 40 – hoursworked Overtimepay = 40- hoursworked Weeklypay = (30* hourlyrate)+ overtimepay Else weeklypay = hoursworked * hourlyrate print (payslip) weeklypay , input data Endif EndifRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.