Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<stdlib.h>
- void load(char *name, float *hours, float *rate, float *federal, float *state)
- {
- printf("Enter name ");
- gets_s(name, 20);
- printf("\nEnter the number of hours they worked ");
- scanf("%f", &*hours);
- printf("\nEnter their hourly rate ");
- scanf("%f", &*rate);
- printf("\nEnter their federal tax rate ");
- scanf("%f", &*federal);
- printf("\nEnter their state tax rate ");
- scanf("%f", &*state);
- }
- 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,
- int *tovp, float *tnp, float *tohours, float *tovt)
- {
- *overtimepeople = 0;
- if (*hours > 40)
- *gp = (float)40 * (*rate) + ((*hours - (float)40) * (float)1.5 * (*rate));
- else
- *gp = *hours * (*rate);
- if (*hours > 40)
- *overtimepeople = *overtimepeople + 1;
- else
- *overtimepeople = *overtimepeople;
- if (*hours > 40)
- *ohours = *hours - 40;
- else
- ohours = 0;
- *ft = *gp * ftr / (float)100;
- *st = *gp * str / (float)100;
- *np = *gp - *ft - *st;
- if (*hours > 40)
- *ovt = (*hours - (float)40) * (float)1.5 * (*rate);
- else
- *ovt = 0.0;
- *tgp += *gp;
- *tfr += *ft;
- *tsr += *st;
- *tovp += *overtimepeople;
- *tnp += *np;
- *tohours += *ohours;
- *tovt += *ovt;
- }
- void print(char *name, float gp, float ft, float st, float np)
- {
- printf("\n\nName: %s\n", name);
- printf("Gross pay; $%0.2f\n", gp);
- printf("Federal tax owed: $%0.2f\n", ft);
- printf("State tax owed: $%0.2f\n", st);
- printf("Net pay: $%0.2f\n\n", np);
- getchar();
- }
- void printtotal(float tgp, float tfr, float tsr, float tnp, int overtimepeople, float tohours, float tovt)
- {
- printf("\nTotal gross pay: %0.2f\n", tgp);
- printf("Total federal tax owed: %0.2f\n", tfr);
- printf("Total state tax owed: %0.2f\n", tsr);
- printf("Total net pay: %0.2f\n", tnp);
- printf("Number of people who did overtime: %d\n", overtimepeople);
- printf("Total overtime hours: %0.2f\n", tohours);
- printf("Total overtime earned: %0.2f\n", tovt);
- system("PAUSE");
- }
- void main()
- {
- float hours, fed, rate, state, ohours, ftaxpaid, staxpaid, netpay, otimepaid, tgp, tsr, tfr, tnp, tohours, tovt, gp;
- int overtimepeople, tovp, i;
- char name[20];
- for (i = 1; i <= 5; i++)
- {
- load(name, &hours, &rate, &fed, &state);
- calc(&hours, &rate, &gp, &overtimepeople, &ohours, &ftaxpaid, &staxpaid, &netpay, fed, state, &otimepaid, &tgp, &tfr, &tsr, &tovp, &tnp, &tohours, &tovt);
- print(name, gp, ftaxpaid, staxpaid, netpay);
- }
- // totals
- printtotal(tgp, tfr, tsr, tnp, tovp, tohours, tovt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement