Asking this question again. The main portion of the question is in bold. Only a
ID: 3580811 • Letter: A
Question
Asking this question again. The main portion of the question is in bold. Only a partial answer was recieved the first time. 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
Hi, Please find my logical explanation.
Please let me know in case of any issue.
Logical Process:
Step1:
Collect all user input
a. number of hours worked
b. hourly wage
Step 2:
IF number_of_hours_worked <= 40, then
calculate gross salary: salary = number_of_hours_worked * hourly_wage
ELSE
extra_hour = number_of_hours_worked - 40
calculate gross salary = number_of_hours_worked*wage + extra_hour*wage*1.5
a IF salary = 600, then:
taxrate = 15%
b ELSE
taxrate = 20%
calculate tax = taxrate*salary
net_pay = salary - tax
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.