#include #include /*number of employees*/ #define NUMBER 5 /*structure for each employee*/ struct Employee { char name[21]; double rate; double hours; }; typedef struct Employee employee; /*function prototypes*/ void userInput(employee *emp); double calcPay(employee emp); double taxes(double pay); void printOut(employee emp); void LoadEmployee(FILE *input, employee *emp); void SaveEmployee(FILE *output, employee emp); int empList(employee *emp, int total); char inputMode(); void EntryPoint(); /*function main begins program execution*/ int main (void) { EntryPoint(); return 0; }//end of main function /*function to prompt user for name, rate, and hours worked*/ void userInput(employee *emp) { printf("Enter name: "); scanf("%s", emp->name); printf("Hourly rate: "); scanf("%lf", &emp->rate); printf("Hours worked: "); scanf("%lf", &emp->hours); }//end of userInput /*function to calculate the gross, base, and overtime pay*/ double calcPay(employee emp) { double total = 0.0, basePay = 0.0, overtimePay = 0.0; if(emp.hours <= 40) //if less than 40 hours worked, pay is the normal base pay { total = emp.rate * emp.hours; basePay = total; } else if (emp.hours > 40) //if over 40 hours worked, pay includes overtime { basePay = 40*emp.rate; overtimePay = 1.5*emp.rate*(emp.hours - 40); total = basePay + overtimePay; } printf("Gross pay: $%7.2f\n", total); printf("Base pay: $%7.2f\n", basePay); printf("Overtime pay: $%7.2f\n", overtimePay); return total; }//end of calcPay /*function to calculate taxes owed*/ double taxes(double pay) { return 0.20*pay; }//end of taxes /*function to print out paycheck details*/ void printOut(employee emp) { double amount = 0.0; printf("Name: %s\n", emp.name); printf("Hours: %.2f\n", emp.hours); printf("Rate: $%7.2f\n", emp.rate); amount = calcPay(emp); printf("Taxes paid: $%7.2f\n", taxes(amount)); printf("Net pay: $%7.2f\n", amount-taxes(amount)); printf("\n"); }//end of printOut void LoadEmployee(FILE *input, employee *emp) { if (input != NULL) printf("bytes=%d\n", fread(emp, sizeof(employee), 1, input)); } void SaveEmployee(FILE *output, employee emp) { if(output !=NULL) fwrite(&emp, sizeof(emp), 1, output); } int empList(employee *emp, int total) { int empNum = 0; int i; printf("Employee List:\n"); for(i=0; i NUMBER) num = NUMBER; for(i=0; i