modify assumption a. in exercise 7 (a. basic pay rate= $10.00/hr), so that the p
ID: 3668845 • Letter: M
Question
modify assumption a. in exercise 7 (a. basic pay rate= $10.00/hr), 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 rates and tax rates
USE C LANGUAGE PLEASE
Explanation / Answer
#include <stdio.h>
#define RATE1 8.75
#define RATE2 9.33
#define RATE3 10.00
#define RATE4 11.20
int main()
{
int rateSelected;
int weeklyHours;
double totalPayed;
double rateToCalculate;
printf("Enter the number corresponding to the desired pay rate or action: ");
printf("1) %.2lf$/hr 2) %.2lf$/hr ", RATE1, RATE2);
printf("3) %.2lf$/hr 4) %.2lf$/hr ", RATE3, RATE4);
printf("5) Quit ");
while ((scanf("%d", &rateSelected)) != EOF && rateSelected != 5)
{
if (rateSelected > 4)
{
printf("please enter a valid number: ");
continue;
}
switch (rateSelected)
{
case 1:
rateToCalculate = RATE1;
break;
case 2:
rateToCalculate = RATE2;
break;
case 3:
rateToCalculate = RATE3;
break;
case 4:
rateToCalculate = RATE4;
break;
};
printf("please enter you weekly hours: ");
scanf("%d", &weeklyHours);
totalPayed = weeklyHours * rateToCalculate;
printf("your paychack for this week is: %.2lf ",totalPayed);
printf("Enter the number corresponding to the desired pay rate or action: ");
printf("1) %.2lf$/hr 2) %.2lf$/hr ", RATE1, RATE2);
printf("3) %.2lf$/hr 4) %.2lf$/hr ", RATE3, RATE4);
printf("5) Quit ");
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.