Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- float wage = ('\0');
- float hours = ('\0');
- float basepay = (wage*hours);
- float OTpay = ('\0');
- float grosspay = (basepay);
- float tax = ('\0');
- float netpay = ('\0');
- int loopcount = ('\0');
- int i;
- char name[20];
- char q[20];
- strcpy_s(q, "quit");
- //inputs
- for (i = 0; i < 5; i++)
- {
- printf("Enter name: ");
- scanf_s("%s", &name, 20);
- if (strcmp(name,q) == -1)
- return;
- printf("Enter hourly rate: ");
- scanf_s("%f", &wage);
- if (wage == -1)
- return;
- printf("Enter hours worked: ");
- scanf_s("%f", &hours);
- if (hours == -1)
- return;
- //calculations
- if (hours > 40){
- OTpay = (hours-40) * (wage*1.5);
- basepay = (40) * (wage);
- grosspay = (basepay + OTpay);
- }
- if (hours < 40){
- OTpay = (0);
- basepay = (wage*hours);
- grosspay = (basepay);
- }
- tax = (grosspay*.20);
- netpay = (grosspay - tax);
- //output
- printf("\nPay to: %s\n", name);
- printf("Hours worked: %.2f\n", hours);
- printf("Hourly rate: %.2f\n", wage);
- printf("Gross pay: %.2f\n", grosspay);
- printf("Base pay: %.2f\n", basepay);
- printf("Overtime pay: %.2f\n", OTpay);
- printf("Taxes paid: %.2f\n", tax);
- printf("Net pay: %.2f\n", netpay);
- printf("----------------------------\n");
- }
- system("Pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement