Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int calcpay(const int rank, const float tax) __attribute__ ((pure));
- int ispayday(const time_t time) __attribute__ ((pure));
- int calcpay(const int rank, const float tax)
- {
- switch rank {
- case 0:
- return (int) (40000.0 * (100.0 - tax));
- case 1:
- return (int) (50000.0 * (100.0 - tax));
- case 2:
- return (int) (60000.0 * (100.0 - tax));
- case 4:
- return (int) (70000.0 * (100.0 - tax));
- }
- return 0;
- }
- int ispayday(const time_t time)
- {
- //Some deterministic function goes here
- }
- /*
- This is the only function where we are permitted to modify e, or any other
- state for that matter.
- */
- void payroll(struct employee **e, const size_t esize)
- {
- int i;
- time_t now;
- time(&now);
- if(ispayday(now)) {
- for(i = 0; i < esize; i++) {
- e[i]->pay = calcpay(e[i]->rank, GLOBAL_TAX);
- /*Deliver pay here - I'm guessing an API call to the financial
- provider*/
- e[i]->ispaid = 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement