Advertisement
trideceth12

Untitled

Oct 24th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. int calcpay(const int rank, const float tax) __attribute__ ((pure));
  2. int ispayday(const time_t time) __attribute__ ((pure));
  3.  
  4. int calcpay(const int rank, const float tax)
  5. {
  6.     switch rank {
  7.         case 0:
  8.             return (int) (40000.0 * (100.0 - tax));
  9.         case 1:
  10.             return (int) (50000.0 * (100.0 - tax));
  11.         case 2:
  12.             return (int) (60000.0 * (100.0 - tax));
  13.         case 4:
  14.             return (int) (70000.0 * (100.0 - tax));
  15.     }
  16.     return 0;
  17. }
  18.  
  19. int ispayday(const time_t time)
  20. {
  21.     //Some deterministic function goes here
  22. }
  23.  
  24. /*
  25. This is the only function where we are permitted to modify e, or any other
  26. state for that matter.
  27. */
  28. void payroll(struct employee **e, const size_t esize)
  29. {
  30.     int i;
  31.     time_t now;
  32.  
  33.     time(&now);
  34.  
  35.     if(ispayday(now)) {
  36.         for(i = 0; i < esize; i++) {
  37.             e[i]->pay = calcpay(e[i]->rank, GLOBAL_TAX);
  38.             /*Deliver pay here - I'm guessing an API call to the financial
  39.             provider*/
  40.             e[i]->ispaid = 1;
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement