Programming language is C++ PA 7-1 (25 points) Write a program to process a payr
ID: 3748055 • Letter: P
Question
Programming language is C++
PA 7-1 (25 points) Write a program to process a payroll for a small company. Calculate gross pay including the possibility of overtime. Calculate payroll tax depending on the employee code and state code. Demonstrate you can use && and/or |I for this program Overtime is paid at the rate of 150% of hourly wages for every hour over 40 Employees with Code B pay no taxes For Code A employee's, If an only 4.5% taxes. I * Code is Y they pay 790; with State Code J pay . * Assume the user does not make any error when inputting data * Display the gross salary, tax, and net salary for each employee e Format the output "professionally" - lined up decimals, etc as shown below D:CodeBlocks-EP1CodeBlocks-EP Marsh2050 binlDebugMarsh2050.exe This program calculates the net pay for each employee At each prompt, enter the requested data. Enter the pay rate: 11.25 Enter the number of hours worked: 53 Enter the employee code (A or B): A Enter the state code (Y or J): Y Regular Pay: 450.00 Overtime Pay: 219.38 Gross Pay: 669.38 46.86 Net Pay: 622.52 D:CodeBlocks-EP CodeBlocks-EP Marsh2050 binDebug Marsh2050.exe his program calculates the net pay for each employee At each prompt, enter the requested data Enter the pay rate: 11.25 Enter the number of hours worked: 53 Enter the employee code (A or B): B Enter the state code (Y or J): J Regular Pay: 450.00 vertime Pay: 219.38 669.38 0.00 ross Pay ax: Net Pay: 669.38Explanation / Answer
#include<iostream>
using namespace std;
float round(float num)
{
float value=(int)(num*100+.5);
return (float)value/100;
}
int main()
{
cout<<"This program calculates the net pay for each employee."<<endl<<endl;
cout<<"At each prompt, enter the requested data."<<endl;
float pay_rate,hours,regular_pay,overtime_pay;
char emp_code,state_code;
cout<<"Enter the pay rate: ";
cin>>pay_rate;
cout<<"Enter the number of hours worked: ";
cin>>hours;
cout<<"Enter the employee code (A or B): ";
cin>>emp_code;
cout<<"Enter the state code (Y or J): ";
cin>>state_code;
regular_pay=40*pay_rate;
if(hours-40>0)
overtime_pay=(hours-40)*(pay_rate +pay_rate*0.5);
else
overtime_pay=0;
float tax=0.0;
if(emp_code=='A'&&state_code=='Y')
tax=(regular_pay+overtime_pay)*7/100;
else if(emp_code=='A'&&state_code=='J')
tax=(regular_pay+overtime_pay)*4.5/100;
cout<<endl<<"Regular Pay: "<<round(regular_pay);
cout<<endl<<"Overtime Pay: "<<round(overtime_pay);
cout<<endl<<"Gross Pay: "<<round(regular_pay+overtime_pay);
cout<<endl<<"tax: "<<round(tax);
cout<<endl<<"--------------------";
cout<<endl<<"Net Pay: "<<round(regular_pay+overtime_pay-tax);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.