/* PAYROLL CALCULATOR BY DOUG TREADWELL LAST MODIFIED BY CREATOR 11/08/06 CISP 360 DIXON PROCESS HIERARCHY : All Include Header.H Most importantly, provides definition of the employee struct, and defines a new "employee" type using that struct to avoid bothersome variable prefixes. Also provides a common output format and tax rate definitions. Start At Main Open Report Files Call PrintReportHeadings (Twice, For Each Report File) Write Report Headings To Presorted And Sorted Report File Until User Declares Last Employee Call InputEmployeeData (Pass Employee Record To Receive Data) Until User Declares Data Entered Correctly Request Employee Data (Last, First, Pay, Hours, Deferred) Call CalculateGross (Pass Employee Record To Calculate Data From) Determine # Regular Hours/Overtime Hours, Calculate Gross Income Call CalculateTaxes (Pass Employee Record To Calculate Data From) Determine Tax Amounts Using Net Income & Defined Tax Rates Call CalculateNet (Pass Employee Record To Calculate Data From) Determine Net Income By Subtracting Taxes From Gross Call AddDetailToAccumulators (Pass Employee Record, Totals Record) Add Employee Record's Values To Totals' Values For Each Employee Call PrintSummaryReport (Pass Presorted File) Write Results of Calculations For Each Employee To File Call PrintReportFooters (Pass Presorted File) Write Accumulated Total & Averages To Presorted File Call BubbleSort Perform Bubble Sort, Placing Names In Descending Alphabetical Order For Each Employee Call PrintSummaryReport (Pass Sorted File) Write Results of Calculations For Each Employee To File Call PrintReportFooters (Pass Sorted File) Write Accumulated Total & Averages To Sorted File Print Report File Footers Close Report Files */ #include #include #include "./Header.h" extern void PrintReportHeadings ( FILE * reportfile ); extern void InputEmployeeData( employee *current_employee ); extern void CalculateGross ( employee *current_employee ); extern void CalculateTaxes ( employee *current_employee ); extern void CalculateNet ( employee *current_employee ); extern void PrintSummaryReport ( FILE * reportfile, employee *current_employee ); extern void AddDetailToAccumulators ( employee *current_employee, employee *employee_totals ); extern void PrintReportFooters ( FILE * reportfile, employee *employee_totals, int number_employees ); extern void Swap ( int *first, int *second ); extern void BubbleSort ( employee employees[], int index[], int number_employees ); extern void QuickSort( employee employees[], int index[], int start, int finish ); extern void PrintChecks( FILE * checks_file, employee employees[], int number_employees ); int main( ) { employee employees[MAX_EMPLOYEES] = {"", "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; employee employee_totals = {"", "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int index[MAX_EMPLOYEES]; int number_employees = 0; int current_employee = 0; int counter = 0; FILE *presortfile; FILE *reportfile; FILE *checks_file; char add_another; presortfile = fopen("./presort.lst","wt"); reportfile = fopen("./report.lst","wt"); checks_file = fopen("./checks.lst","wt"); if (!reportfile || !presortfile) { printf("Could not open one or more report files. Ending program."); exit(10); } PrintReportHeadings( presortfile ); PrintReportHeadings( reportfile ); do { number_employees++; current_employee = number_employees - 1; index[current_employee] = current_employee; InputEmployeeData( &employees[current_employee] ); CalculateGross( &employees[current_employee] ); CalculateTaxes( &employees[current_employee] ); CalculateNet ( &employees[current_employee] ); AddDetailToAccumulators ( &employees[current_employee], &employee_totals ); printf("\nWould you like to add another employee? : (Y or N)\n>"); fflush(stdin); scanf("%c", &add_another); } while ( add_another == 'Y' || add_another == 'y' ); for ( counter = 0; counter < number_employees; counter++ ) { PrintSummaryReport ( presortfile, &employees[index[counter]] ); } PrintReportFooters ( presortfile, &employee_totals, number_employees ); BubbleSort( employees, index, number_employees ); //QuickSort( employees, index, 0, number_employees - 1); PrintChecks( checks_file, employees, number_employees ); for ( counter = 0; counter < number_employees; counter++ ) { PrintSummaryReport ( reportfile, &employees[index[counter]] ); } PrintReportFooters ( reportfile, &employee_totals, number_employees ); fclose(presortfile); fclose(reportfile); fclose(checks_file); return 0; }