Write a program that reads in the name, hourly rate and number of hours worked for 5 people. Print the name of each person, the number of hours worked, their weekly pay based on the number of hours they worked and how much they owe in taxes. Assume that taxes take 20% of the paycheck. Don’t forget to take the taxes out of the pay check. If they work more than 40 hours they get overtime. The hourly rate is then 1.5 times normal for all hours past 40.
Example (Sample input & output for one person)
Enter name: Jian an Liu
Enter hourly rate: 4.00
Enter hours worked: 75
Pay to: Jian an Liu
Hourly rate: 4.00
Hours worked: 75.0
Amount paid: $370.00
Taxes paid: $74.00
Take home: $296.00
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
#include <stdio.h>
int main()
{int i;
for(i=0;i<5;i++)
{
double rate, hours, tax, salary,paid;
char name[100];
fflush(stdin);
printf("Enter name: ");
scanf("%[^\n]s",&name);
printf("Enter hourly rate: ");
scanf("%lf",&rate);
printf("Enter hours worked: ");
scanf("%lf",&hours);
printf("Pay to: %s \n",name);
printf("Hourly rate: %.2f\n",rate);
printf("Hours worked: %.2f\n",hours);
if(hours>40)
{salary=rate*40;
hours-=40;
salary=salary+(hours*(rate*1.5));
}
else
salary=hours*rate;
tax=salary*.2;
paid=salary-tax;
printf("Amount paid: $%.2f\n",salary);
printf("Taxes paid: $%.2f\n",tax);
printf("Take home: $%.2f\n\n",paid);
}
return 0;
}
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.