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

1. Use C program by using Visual Studio: a. Write a program that can sort 3 inpu

ID: 3796583 • Letter: 1

Question

1. Use C program by using Visual Studio:

a. Write a program that can sort 3 input integer numbers and output the minimum and maximum values.

b.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:

-Basic pay rate= $10.00/hr

-Overtime (in excess of 40 hours)= time and a half

-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 dose not conform to current tax law.

Explanation / Answer

a)

B)

#include <stdio.h>
#include <ctype.h>
#define TXRATE1 0.15
#define TXRATE2 0.20
#define TXRATE3 0.25
#define BASEPAY 10

int main(void)
{
   int hrs = 0;               // the number of hours worked
   int othrs = 0;               // the number of hrs over 40
   float grosspay = 0.0;           // gross pay
   float netpay = 0.0;           // net pay
float taxes   = 0.0;           // taxes
   int choice   =0;           // menu choice
  

   // get the hours worked
   printf(" It's time to get paid. ");
   printf("Please enter the number of hours you worked this week: ");
   scanf(" %d",&hrs);

  
   // calculate normal and OVERTIME HOURS hours
  
   if(hrs < 40)
   {
      othrs = 0;
   }
   else
   {
      othrs = hrs - 40;
      hrs = 40;
   }
     
   // calculate the gross pay
     
   grosspay = (hrs * BASEPAY) + (othrs * BASEPAY * 1.5);
     
   // calculate taxes
     
   if (grosspay <= 300.00)
   {
      taxes =   grosspay * TXRATE1;
      netpay = grosspay - taxes;
   }  
   else if (grosspay <= 450.00)
   {   taxes = ((grosspay - 300)*TXRATE2) + (300.00*TXRATE1);
      netpay = grosspay - taxes;
   }
   else
   {  
      taxes = ((grosspay - 450.00)*TXRATE3) + (150.00*TXRATE2) + (300.00*TXRATE1);
      netpay = grosspay - taxes;
   }  
   // display the results
  
   printf("Gross Pay: %.2f ",grosspay);
   printf("Taxes : %.2f ",taxes);
   printf("Net Pay : %.2f ",netpay);
  
   return 0;   // end program
}