In: Computer Science
In C program
#include<stdio.h>
You found an exciting summer job for five weeks.
Suppose that the total tax you pay on your summer job income is 14%.
After paying the taxes, you spend:
Write a program that prompts the user to enter the pay rate for
an hour and
the number of hours you worked each week.
For example, if you earned $10.00/hour and worked 10 hours per
week....
the program should output the following:
|----------|--------------------------------------------------|
| $ 10.00 | Hourly Rate |
| 50.00 | Total Hours Worked |
|----------|--------------------------------------------------|
| $ 500.00 | Total Income before tax |
| $ 430.00 | Net Income |
| $ 43.00 | Money spent on clothes and other accessories |
| $ 4.30 | Money spent on school supplies |
| $ 95.67 | Money spent on savings |
| $ 47.84 | Money spent by parents on additional savings |
|----------|--------------------------------------------------|
REQUIREMENT: Use printf format descriptors to
format the rows of the table.
A C program for above furnished information is as below :
#include <stdio.h>
int main()
{
float hr,hw,thw,tibt,ni,mc,ms,msa,ab,mas;
printf("Please enter rate per hour(without currency symbol)
:");
scanf("%f",&hr);
printf("\n");
printf("Please enter worked hours per week :");
scanf("%f",&hw);
printf("\n");
thw=hw*5;
printf("|--------|---------------------------------------------|\n");
printf("|$%.2f| Hourly Rates|\n",hr);
printf("|%.2f|Total Hours Worked|\n",thw);
printf("|--------|---------------------------------------------|\n");
tibt=(((hr*thw)*100)/100);
printf("|$%.2f|Total Income before tax|\n",tibt);
ni=(tibt - ((tibt*14)/100));
printf("|$%.2f|Net Income|\n",ni);
mc=(ni/10);
printf("|$%.2f|Money spent on clothes and other
accessories|\n",mc);
ms=(mc/10);
printf("|$%.2f|Money spent on school supplies|\n",ms);
msa=((((ni-mc-ms)*25)/100));
ab=floor(msa*100)/100;
printf("|$%.2f|Money spent on savings|\n",ab);
mas=(msa/2);
printf("|$%.2f|Money spent by parents on additional
savings|\n",mas);
printf("|--------|---------------------------------------------|\n");
return 0;
}
Note : - It used float data type and while entering hourly rate , please ignore $ symbol for hourly rate.