rendered paste body#include <stdio.h>#include <string.h>/*number of employees*/#define NUMBER 5/*structure for each employee*/struct employee{ char name[21]; double rate; double hours;};/*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);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 printOutvoid LoadEmployee(FILE *input, employee *emp){ if (input != NULL) fread(emp, sizeof(struct employee), 1, input);}void SaveEmployee(FILE *output, employee emp){ if(output !=NULL) fwrite(&emp, sizeof(emp), 1, output);}int empList(employee *emp){ int empNum = 0; printf("Employee List:\n"); for(int i=0; i<NUMBER; i++) { if(emp[i].name != NULL) printf("%d) %s", i, emp[i].name); else break; } printf("Enter Number: "); scanf("%d\n", &empNum); return empNum;}/*Function to prompt user for input mode*/char InputMode(){ char input; printf("Please choose a data source: \n"); printf("F) File\nK) Keyboard\nQ) Quit\n"); scanf("%c", &input); return input;}void EntryPoint(){ struct employee employees[NUMBER] = { }; int num = 0; FILE *empFile = fopen("c://employees.txt", "r"); switch (InputMode()) { case 'f': case 'F': for(int i=0; i<NUMBER; i++) { if(empFile != NULL) LoadEmployee(empFile, &employees[i]); } break; case 'k': case 'K': printf("Number of Employees (less than %d): ", NUMBER); scanf("%d\n", &num); if(num > NUMBER) num = NUMBER; for(int i=0; i<num; i++) { userInput(&employees[i]); if(employees[i].rate == -1 || employees[i].hours == -1) break; } break; default: break; } int choice = 0; do { printf("Choose from the following: \n"); printf("1) Update Data\n"); printf("2) Print One Employee Data\n"); printf("3) Print All Employee Data\n"); printf("4) Save to File\n"); printf("5) Quit\n"); printf("Enter number: "); scanf("%d\n", &choice); int empNum = 0; switch(choice) { case 1: empNum = empList(employees); userInput(&employees[empNum]); continue; case 2: empNum = empList(employees); printOut(employees[empNum]); continue; case 3: for(int i=0; i<NUMBER; i++) { if(!feof(empFile)) printOut(employees[i]); else break; } continue; case 4: for(int i=0; i<NUMBER; i++) SaveEmployee(empFile, employees[i]); continue; default: break; } }while(choice != 5 && choice != 0); // update employee record // show employee record for(int i=0; i<NUMBER; i++) SaveEmployee(empFile, employees[i]); fclose(empFile); printf("End of run. Employee data saved to c://employee.txt");}