Really stuck on this. In a brief paper, describe the C program written below . S
ID: 3580709 • Letter: R
Question
Really stuck on this. In a brief paper, describe the C program written below. Stating the requirements for the program and discuss the logical process the program uses to meet those requirements.
#include<stdio.h>
int main()
{
int hwork,hwage,taxrate,tax,othour,otwage;
float salary,netpay;
printf("enter hours worked in a week ");
scanf("%d",&hwork);
printf("enter hourly wage ");
scanf("%d",&hwage);
if(hwork<=40)
{
salary=hwork*hwage;
if(salary<=600)
{
taxrate=15;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf("Gross Pay Tax Rate Net Pay ");
printf("$ %f $ %d(15%%) $ %f ",salary,tax,netpay);
}
else
{
taxrate=20;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf("Gross Pay Tax Rate Net Pay ");
printf("$ %f $ %d(20%%) $ %f ",salary,tax,netpay);
}
}
else
{
othour=hwork-40;
otwage=hwage+(hwage/2);
salary=(40*hwage)+(othour*otwage);
if(salary<=600)
{
taxrate=15;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf("Gross Pay Tax Rate Net Pay ");
printf("$ %f $ %d(15%%) $ %f ",salary,tax,netpay);
}
else
{
taxrate=20;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf("Gross Pay Tax Rate Net Pay ");
printf("$ %f $ %d(20%%) $ %f ",salary,tax,netpay);
}
}
return 0;
}
Explanation / Answer
This program calculates the tax payable by an employee and hence calculates the gross pay, tax rate and net pay to the employee.
It takes input the following:
1. Hours worked in a week
2. Hourly wage
Then if the number of hours worked is less than 40, it calculates the salary by multiplying hourly wage by hours worked. Then if the salary is less than 600, tax rate is 15. Tax, netpay are calculated and gross pay, tax rate and net pay are printed out.
However, if salary is more than 600, tax rate is 20. Tax, netpay are calculated and gross pay, tax rate and net pay are printed out.
If the number of hours worked is more than 40, extra hours are calculated after 40.Then if the salary is less than 600, tax rate is 15. Tax, netpay are calculated and gross pay, tax rate and net pay are printed out.
However, if salary is more than 600, tax rate is 20. Tax, netpay are calculated and gross pay, tax rate and net pay are printed out.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.