Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.65 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4.  
  5. void load(char *name, float *hours, float *rate, float *federal, float *state)
  6. {
  7.     printf("Enter name   ");
  8.     gets_s(name, 20);
  9.  
  10.     printf("\nEnter the number of hours they worked   ");
  11.     scanf("%f", &*hours);
  12.  
  13.     printf("\nEnter their hourly rate   ");
  14.     scanf("%f", &*rate);
  15.  
  16.     printf("\nEnter their federal tax rate   ");
  17.     scanf("%f", &*federal);
  18.  
  19.     printf("\nEnter their state tax rate   ");
  20.     scanf("%f", &*state);
  21. }
  22.  
  23. void calc(float *hours, float *rate, float *gp, int *overtimepeople, float *ohours, float *ft, float *st, float *np, float ftr, float str, float *ovt, float *tgp, float *tfr, float *tsr,
  24.     int *tovp, float *tnp, float *tohours, float *tovt)
  25. {
  26.     *overtimepeople = 0;
  27.  
  28.     if (*hours > 40)
  29.         *gp = (float)40 * (*rate) + ((*hours - (float)40) * (float)1.5 * (*rate));
  30.     else
  31.         *gp = *hours * (*rate);
  32.     if (*hours > 40)
  33.         *overtimepeople = *overtimepeople + 1;
  34.     else
  35.         *overtimepeople = *overtimepeople;
  36.     if (*hours > 40)
  37.         *ohours = *hours - 40;
  38.     else
  39.         ohours = 0;
  40.     *ft = *gp * ftr / (float)100;
  41.     *st = *gp * str / (float)100;
  42.     *np = *gp - *ft - *st;
  43.     if (*hours > 40)
  44.         *ovt = (*hours - (float)40) * (float)1.5 * (*rate);
  45.     else
  46.         *ovt = 0.0;
  47.     *tgp += *gp;
  48.     *tfr += *ft;
  49.     *tsr += *st;
  50.     *tovp += *overtimepeople;
  51.     *tnp += *np;
  52.     *tohours += *ohours;
  53.     *tovt += *ovt;
  54.  
  55.  
  56. }
  57. void print(char *name, float gp, float ft, float st, float np)
  58. {
  59.     printf("\n\nName: %s\n", name);
  60.     printf("Gross pay; $%0.2f\n", gp);
  61.     printf("Federal tax owed: $%0.2f\n", ft);
  62.     printf("State tax owed: $%0.2f\n", st);
  63.     printf("Net pay: $%0.2f\n\n", np);
  64.     getchar();
  65. }
  66.  
  67.  
  68.  
  69. void printtotal(float tgp, float tfr, float tsr, float tnp, int overtimepeople, float tohours, float tovt)
  70. {
  71.     printf("\nTotal gross pay: %0.2f\n", tgp);
  72.     printf("Total federal tax owed: %0.2f\n", tfr);
  73.     printf("Total state tax owed: %0.2f\n", tsr);
  74.     printf("Total net pay: %0.2f\n", tnp);
  75.     printf("Number of people who did overtime: %d\n", overtimepeople);
  76.     printf("Total overtime hours: %0.2f\n", tohours);
  77.     printf("Total overtime earned: %0.2f\n", tovt);
  78.     system("PAUSE");
  79. }
  80.  
  81. void main()
  82. {
  83.     float hours, fed, rate, state, ohours, ftaxpaid, staxpaid, netpay, otimepaid, tgp, tsr, tfr, tnp, tohours, tovt, gp;
  84.     int overtimepeople, tovp, i;
  85.     char name[20];
  86.     for (i = 1; i <= 5; i++)
  87.     {
  88.         load(name, &hours, &rate, &fed, &state);
  89.         calc(&hours, &rate, &gp, &overtimepeople, &ohours, &ftaxpaid, &staxpaid, &netpay, fed, state, &otimepaid, &tgp, &tfr, &tsr, &tovp, &tnp, &tohours, &tovt);
  90.         print(name, gp, ftaxpaid, staxpaid, netpay);
  91.     }
  92.  
  93.     // totals
  94.     printtotal(tgp, tfr, tsr, tnp, tovp, tohours, tovt);
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement