Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

8. Modify assumption a. in exercise 7 so that the program presents a menu of pay

ID: 3664361 • Letter: 8

Question

8. Modify assumption a. in exercise 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: 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.

this is my code but it is not executing properly. i do not know the reasons for that.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int choice, hour;
    float taxe, total;

    printf("**************************************************************** ");
    printf(" Enter the number corresponding to the desired pay rate or action");
    printf(" 1)$8.75/hr");
    printf(" 2)$9.33/hr");
    printf(" 3)$10.00/hr");
    printf(" 4)$11.20hr");
    printf(" 5)Quit");
    printf("********************************************************** ");

    scanf("%d", &choice);

    printf("Please enter number of hours: ");
    scanf("%d", &hour);

    switch(choice){
    case 1:
        total = 8.75* hour;
        break;
    case 2:
        total = 9.33*hour;
        break;
    case 3:
        total = 10.00*hour;
        break;
    case 4:
        total = 11.20*hour;
        break;
    case 5:
         break;
    return 0;
    }
}

Explanation / Answer

The syntax of switch case is

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int choice, hour;
float total;

printf("******************************** ");   

printf(" 1) $8.75/hr");
    printf(" 2) $9.33/hr");
    printf(" 3) $10.00/hr");
    printf(" 4) $11.20hr");
    printf(" 5) Quit");

  printf("******************************** ");

printf(" Enter your choice : ");

  scanf("%d", &choice);

    printf("Please enter number of hours: ");
    scanf("%d", &hour);

    switch(choice){
    case 1:
        total = 8.75* hour;

printf(" Total is :%f",total);
        break;
    case 2:
        total = 9.33*hour;

  printf(" Total is :%f",total);       

break;
    case 3:
        total = 10.00*hour;

printf(" Total is :%f",total);       

break;
    case 4:
        total = 11.20*hour;

printf(" Total is :%f",total);       

break;
case 5:
         break;
    return 0;
    }
}

Output:

********************************

1) $8.75/hr

2) $9.33/hr

3) $10.00/hr

4) $11.20hr

5) Quit

********************************

Enter your choice : 3

Please enter number of hours: 7

Total is : 70.00

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote