Code:
#include <stdio.h>
int max_array(int a[], int num_elements);
int employee1, employee2, employee3, employee4, employee5, premium, emp1stndpay, emp1overpay, emp1pay, emp1overtpay, emp1total, emp2stndpay, emp2overpay, emp2pay, emp2overtpay, emp2total, emp3stndpay, emp3overpay, emp3pay, emp3overtpay, emp3total, emp4stndpay, emp4overpay, emp4pay, emp4overtpay, emp4total, emp5stndpay, emp5overpay, emp5pay, emp5overtpay, emp5total, totalpay;
void print_array(int a[], int num_elements);
void main(void)
{
printf ("----------------------------Pay Program-----------------------\n "); /* prompt */
printf ("Enter the overtime premium (%): "); /* prompt */
scanf ("%d", &premium); /* read integer */
printf ("***************************************************************\n "); /* prompt */
printf ("Please enter number of hours worked this week by EMPLOYEE1: "); /* prompt */
scanf ("%d", &employee1); /* read integer */
if (employee1<38)
printf ("--The standard hours worked by employee1 would be = %d\n", employee1); /* print sum */
else
printf ("--The standard hours worked by employee1 would be = %d\n", 38); /* print sum */
if ((employee1-38)<0)
printf ("--The overtime hours worked by employee1 would be = %d\n", 0); /* print sum */
else
printf ("--The overtime hours worked by employee1 would be = %d\n", (employee1-38)); /* print sum */
printf ("Please confirm amount of standard hours to be worked: "); /* prompt */
scanf ("%d", &emp1stndpay); /* read integer */
printf ("Please confirm amount of overtime hours to be worked: "); /* prompt */
scanf ("%d", &emp1overpay); /* read integer */
emp1pay = emp1stndpay * 5.75;
printf ("--Standard pay = %d\n", emp1pay); /* print sum */
emp1overtpay = (((5.75/100)* premium)+5.75) * emp1overpay;
printf ("--Overtime pay = %d\n", emp1overtpay); /* print sum */
emp1total = emp1overtpay + emp1pay;
printf ("--The total weeks pay for Employee 1 = %d\n", emp1total); /* print sum */
printf ("***************************************************************\n "); /* prompt */
printf ("Please enter number of hours worked this week by EMPLOYEE2: "); /* prompt */
scanf ("%d", &employee2); /* read integer */
if (employee2<38)
printf ("--The standard hours worked by employee2 would be = %d\n", employee2); /* print sum */
else
printf ("--The standard hours worked by employee2 would be = %d\n", 38); /* print sum */
if ((employee2-38)<0)
printf ("--The overtime hours worked by employee2 would be = %d\n", 0); /* print sum */
else
printf ("--The overtime hours worked by employee2 would be = %d\n", (employee2-38)); /* print sum */
printf ("Please confirm amount of standard hours to be worked: "); /* prompt */
scanf ("%d", &emp2stndpay); /* read integer */
printf ("Please confirm amount of overtime hours to be worked: "); /* prompt */
scanf ("%d", &emp2overpay); /* read integer */
emp2pay = emp2stndpay * 5.75;
printf ("--Standard pay = %d\n", emp2pay); /* print sum */
emp2overtpay = (((5.75/100)* premium)+5.75) * emp2overpay;
printf ("--Overtime pay = %d\n", emp2overtpay); /* print sum */
emp2total = emp2overtpay + emp2pay;
printf ("--The total weeks pay for Employee 2 = %d\n", emp2total); /* print sum */
printf ("***************************************************************\n "); /* prompt */
printf ("Please enter number of hours worked this week by EMPLOYEE3: "); /* prompt */
scanf ("%d", &employee3); /* read integer */
if (employee3<38)
printf ("--The standard hours worked by employee3 would be = %d\n", employee3); /* print sum */
else
printf ("--The standard hours worked by employee3 would be = %d\n", 38); /* print sum */
if ((employee1-38)<0)
printf ("--The overtime hours worked by employee3 would be = %d\n", 0); /* print sum */
else
printf ("--The overtime hours worked by employee3 would be = %d\n", (employee3-38)); /* print sum */
printf ("Please confirm amount of standard hours to be worked: "); /* prompt */
scanf ("%d", &emp3stndpay); /* read integer */
printf ("Please confirm amount of overtime hours to be worked: "); /* prompt */
scanf ("%d", &emp3overpay); /* read integer */
emp3pay = emp3stndpay * 5.75;
printf ("--Standard pay = %d\n", emp3pay); /* print sum */
emp3overtpay = (((5.75/100)* premium)+5.75) * emp3overpay;
printf ("--Overtime pay = %d\n", emp3overtpay); /* print sum */
emp3total = emp3overtpay + emp3pay;
printf ("--The total weeks pay for Employee 3 = %d\n", emp3total); /* print sum */
printf ("***************************************************************\n "); /* prompt */
printf ("Please enter number of hours worked this week by EMPLOYEE4: "); /* prompt */
scanf ("%d", &employee4); /* read integer */
if (employee4<38)
printf ("--The standard hours worked by employee4 would be = %d\n", employee4); /* print sum */
else
printf ("--The standard hours worked by employee4 would be = %d\n", 38); /* print sum */
if ((employee4-38)<0)
printf ("--The overtime hours worked by employee4 would be = %d\n", 0); /* print sum */
else
printf ("--The overtime hours worked by employee4 would be = %d\n", (employee4-38)); /* print sum */
printf ("Please confirm amount of standard hours to be worked: "); /* prompt */
scanf ("%d", &emp4stndpay); /* read integer */
printf ("Please confirm amount of overtime hours to be worked: "); /* prompt */
scanf ("%d", &emp4overpay); /* read integer */
emp4pay = emp4stndpay * 5.75;
printf ("--Standard pay = %d\n", emp4pay); /* print sum */
emp4overtpay = (((5.75/100)* premium)+5.75) * emp4overpay;
printf ("--Overtime pay = %d\n", emp4overtpay); /* print sum */
emp4total = emp4overtpay + emp4pay;
printf ("--The total weeks pay for Employee 4 = %d\n", emp4total); /* print sum */
printf ("***************************************************************\n "); /* prompt */
printf ("Please enter number of hours worked this week by EMPLOYEE5: "); /* prompt */
scanf ("%d", &employee5); /* read integer */
if (employee5<38)
printf ("--The standard hours worked by employee5 would be = %d\n", employee5); /* print sum */
else
printf ("--The standard hours worked by employee5 would be = %d\n", 38); /* print sum */
if ((employee5-38)<0)
printf ("--The overtime hours worked by employee5 would be = %d\n", 0); /* print sum */
else
printf ("--The overtime hours worked by employee5 would be = %d\n", (employee5-38)); /* print sum */
printf ("Please confirm amount of standard hours to be worked: "); /* prompt */
scanf ("%d", &emp5stndpay); /* read integer */
printf ("Please confirm amount of overtime hours to be worked: "); /* prompt */
scanf ("%d", &emp5overpay); /* read integer */
emp5pay = emp5stndpay * 5.75;
printf ("--Standard pay = %d\n", emp5pay); /* print sum */
emp5overtpay = (((5.75/100)* premium)+5.75) * emp5overpay;
printf ("--Overtime pay = %d\n", emp5overtpay); /* print sum */
emp5total = emp5overtpay + emp5pay;
printf ("--The total weeks pay for Employee 5 = %d\n", emp5total); /* print sum */
printf ("***************************************************************\n "); /* prompt */
totalpay = emp1total + emp2total + emp3total + emp4total + emp5total;
printf ("--The total weeks pay for all Employees = %d\n", totalpay); /* print sum */
printf ("--------------------------------------------------------------\n "); /* prompt */
int a[10] = {emp1total, emp2total, emp3total, emp4total, emp5total, 0, 0, 0, 0, 0};
int max;
/*printf("\nArray:\n");*/
/*print_array(a, 10);*/
max = max_array(a, 10);
printf("The max is %d\n", max);
if (max = emp1total)
printf ("--Employee1 is paid the most"); /* print sum */
if (max = emp2total)
printf ("--Employee2 is paid the most"); /* print sum */
if (max = emp3total)
printf ("--Employee3 is paid the most"); /* print sum */
if (max = emp4total)
printf ("--Employee4 is paid the most"); /* print sum */
if (max = emp5total)
printf ("--Employee5 is paid the most"); /* print sum */
}
int max_array(int a[], int num_elements)
{
int i, max=-32000;
for (i=0; i<num_elements; i++)
if (a[i]>max)
max=a[i];
return(max);
}
void print_array(int a[], int num_elements)
{
int i;
for(i=0; i<num_elements; i++)
printf("%d ", a[i]);
printf("\n");
}
[code][/code]