#include struct employee { char *name; int age; int classification; int hours_worked; float overtime; float gross_salary; float net_salary; }; void descdend_order(struct employee descend[]) { int left, right; struct employee temp; for ( left = 0; left < 4; ++left ) //nested for loop for arrays once the right arrays loop is done the left will advance one untill all arrays are checked for ( right = left + 1; right < 5; ++right) if ( descend[left].net_salary < descend[right].net_salary ) //if the left data is larger then right data, then it will execute the following { temp = descend[left].net_salary; // temp is set to the left integer descend[left].net_salary = descend[right].net_salary; //the left data is swaped with the right data descend[right].net_salary = temp; //the right data is now set to the temp value } } int main (void) { struct employee descend_order(struct employee descend); struct employee emp; struct employee data[5] = { {"John Miller", 42, 2, 38}, {"Michael Wick", 34, 1, 34}, {"Maria Garcia", 30, 3, 25}, {"Jose Garcia", 27, 4, 45}, {"Nathan Aston", 24, 1, 55} }; int i; printf("Original Data Below \n"); printf("--------------------------------------------------------------------------------------------------\n"); for (i = 0; i<=4; ++i) { if(data[i].hours_worked < 41) { if(data[i].classification == 1){ emp.gross_salary = data[i].hours_worked * 10.25; } //end of class 1 else if(data[i].classification ==2){ emp.gross_salary = data[i].hours_worked *8.50; } //end of class 2 else if(data[i].classification == 3) { emp.gross_salary = data[i].hours_worked *6.30; } //end of class 3 else if (data[i].classification == 4) { emp.gross_salary = data[i].hours_worked *4.65; } //end of class 4 } // end of if loop <= 40 hours else{ if(data[i].classification == 1){ emp.overtime = (data[i].hours_worked - 40) * 10.25; emp.gross_salary = data[i].hours_worked *10.25 + emp.overtime; } //end of class 1 else if(data[i].classification ==2){ emp.overtime = (data[i].hours_worked - 40) *8.50; emp.gross_salary = data[i].hours_worked *8.50 + emp.overtime; } //end of class 2 else if(data[i].classification == 3) { emp.overtime = (data[i].hours_worked - 40) * (6.30 *1.5); emp.gross_salary = data[i].hours_worked *6.30 + emp.overtime; } //end of class 3 else if (data[i].classification == 4) { emp.overtime = (data[i].hours_worked - 40) *(4.65 * 1.5); emp.gross_salary = data[i].hours_worked *4.65 + emp.overtime; } //end of class 4 } //end of overtime else loop if(emp.gross_salary <= 200){ emp.net_salary = emp.gross_salary -(emp.gross_salary * .12); } // tax rate for 12% else if(emp.gross_salary > 200 || emp.gross_salary <=350){ emp.net_salary = emp.gross_salary - (emp.gross_salary * .15) ; } //tax rate for 15% else if (emp.gross_salary > 350){ emp.net_salary = emp.gross_salary -(emp.gross_salary * .18); } printf("Name : %s | Age : %i | Classificatin : %i | Hours Worked :%i | Gross Salary : $%.2f | Net Salary : $%.2f \n", data[i].name, data[i].age, data[i].classification, data[i].hours_worked, emp.gross_salary, emp.net_salary); data[i] = descend_order(data[i]); printf("Name : %s | Age : %i | Classificatin : %i | Hours Worked :%i | Gross Salary : $%.2f | Net Salary : $%.2f \n", data[i].name, data[i].age, data[i].classification, data[i].hours_worked, emp.gross_salary, emp.net_salary); } //end of for loop return 0; }