The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Could you please run the program and send me a screen shot ?
Â
Â
#include<stdio.h>
#define
#define
#define
#define
#define
#define
#define
#define PAY_RATE_1 8.75f
PAY_RATE_2 9.33f
PAY_RATE_3 10.00f
PAY_RATE_4 11.20f
TAX_RATE_FIRST_300 0.15f
TAX_RATE_NEXT_150 0.20f
TAX_RATE_REST 0.25f
OVERTIME_RATE 1.5f int main()
{
int choice;
int hoursWorked;
float payRate;
float grossPay;
float taxes;
float netPay;
float overtimePay = 0;
printf("******************************************************************\n\n")
;
printf("Enter the number corresponding to the desired pay rate or
action:\n\n");
printf("1) $8.75/hr\t\t\t\t2) $9.33/hr\n\n");
printf("3) $10.00/hr\t\t\t\t4) $11.20/hr\n\n");
printf("5) quit\n\n");
printf("******************************************************************\n\n")
;
scanf("%d", &choice);
// if entered choice is invalid, recycle
while(choice < 1 || choice > 5)
{
printf("\nWrong choice! Please select correct option\n\n");
printf("******************************************************************\n\n")
;
printf("Enter the number corresponding to the desired pay rate or
action:\n\n");
printf("1) $8.75/hr\t\t\t\t2) $9.33/hr\n\n");
printf("3) $10.00/hr\t\t\t\t4) $11.20/hr\n\n");
printf("5) quit\n\n");
printf("******************************************************************\n\n")
;
} scanf("%d", &choice); // ask for hours worked
printf("\nPlease enter the number of hours worked: ");
scanf("%d", &hoursWorked);
// set pay rate as per the choice
switch(choice)
{
case 1:
payRate = PAY_RATE_1;
break;
case 2: payRate = PAY_RATE_2;
break;
case 3:
payRate = PAY_RATE_3;
break;
case 4:
payRate = PAY_RATE_4;
break;
case 5:
return 0;
}
// check if overtime and gross pay
if(hoursWorked > 40)
{
overtimePay = (hoursWorked - 40) * payRate * OVERTIME_RATE;
grossPay = (40 * payRate) + overtimePay;
}
else
{
grossPay = hoursWorked * payRate;
}
// calculate taxes
if(grossPay <= 300)
taxes = grossPay * TAX_RATE_FIRST_300;
else if(grossPay <= 450)
taxes = grossPay * TAX_RATE_NEXT_150;
else
taxes = grossPay * TAX_RATE_REST;
// calculate net pay
netPay = grossPay - taxes;
// display gross pay, taxes and net pay
printf("\n\nGross Pay: $%.2f", grossPay);
printf("\nTaxes: $%.2f", taxes);
printf("\nNet Pay: $%.2f", netPay);
return 0;
}
-----------