/* June 09 */ /* program to compute total payroll and average payroll using While and Functions */ #include /* function prototype */ double calc_pay(double h, double r); main () { /* declarations */ int count_emp; /* current employee */ int number_emp; /* number of employees */ double total_pay; /* company payroll */ double rate; /* hourly pay rate */ double hours; /* hours worked */ double average; /* average pay per employee */ /* get number of employees */ printf("Enter number employees> "); scanf("%d", &number_emp); /* calculates each employee's pay and add it to the payroll */ total_pay = 0.0; count_emp = 1; while (count_emp <= number_emp) { printf("Hours> "); scanf("%lf", &hours); printf("Rate> $"); scanf("%lf", &rate); /* display each employee's pay */ printf("Employee #%d's pay is $%6.2f\n\n", count_emp, calc_pay(hours, rate)); /* Adds to the next pay */ total_pay = total_pay + calc_pay(hours, rate); count_emp = count_emp +1; } /* display total payroll of all employees */ printf("Total payroll is $%8.2f\n", total_pay); average = total_pay / number_emp; /* display average payroll per employee */ printf("Average payroll is $%8.2f\n", average); } double calc_pay(double h, double r) { /* computation */ return (h * r); }