*** #7 is needed to answer #8. Code must be in C. *** #7. Write a program that r
ID: 668523 • Letter: #
Question
*** #7 is needed to answer #8. Code must be in C. ***
#7. Write a program that requests the hours worked in a week and then prints the gross pay, the taxes, and the net pay. Assume the following:
a. Basic pay rate = $10.00/hr
b. overtime (in excess of 40 hours) = time and a half
c. Tax rate: #15% of the first $300
20% of the next $150
25% of the rest
Use #define constants, and don't worry if the example does not conform to current tax law.
#8. MOdify assumption a. in #7 so that the program presents a menu of pay rates from which to choose. Use a switch to select the pay rate. The beginning of a run should look something like this:
**************************************************************************'
Enter the number corresponding to the desired pay rate or action:
1) $8.75/hr 2) $9.33/hr
3) $10.00/hr 4) $11.20/hr
5) quit
***************************************************************************
If choices 1 through 4 are selected, the program should request the hours worked. The Program should recycle until 5 is entered. If something other than choices 1 through 5 is entered, the program should remind the user what the proper choices are and then recycle. Use #defined constants for the various earning ratres and tax rates.
*** please put explanations for each line of code so I can learn from it please! ***
Explanation / Answer
#include<stdio.h>
#include<conio.h>
#define a 15.0;
#define b 20.0;
#define c 25.0;
void main()
{
int ch,h;
float tax,tot;
clrscr();
printf("******************************************************************");
printf(" Enter the number corresponding to the desired pay rate oa action");
printf(" 1)$8.75/hr");
printf(" 2)$9.33/hr");
printf(" 3)$10.00/hr");
printf(" 4)$11.20/hr");
printf(" 5)Quit");
printf("******************************************************************");
scanf("%d",&ch);
printf("Pl. enter number of hours");
scanf("%d",&h);
switch(ch)
{
case 1:
tot=8.75*h;
break;
case 2:
tot=9.33*h;
break;
case 3:
tot=10.00*h;
break;
case 4:
tot=11.20*h;
break;
case 5:
return;
break;
default:
printf("Pl. enter 1-5 onlt");
break;
}
if(tot<=300)
{
tax=tot*15/100;
}
else if(tot<=450)
{
tax=45+((tot-300)*20/100);
}
else
{
tax=45+30+((tot-450)*25/100);
}
printf("Gross Pay is %f",tot);
printf(" Tax is %f",tax);
printf(" Net Pay is %f",tot-tax);
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.