PROGRAM
#include<stdio.h>
#include<string.h>
/* structure declare */
struct employee
{
char name[15];
long id_number;
float wage;
float hours;
float overtime;
float gross;
};
main()
{
/* array of structure with 5 elements */
struct employee e[5];
/* pointer declare */
struct employee *emp = NULL;
/* pointer points the first element address of
structure */
emp=e;
/* variable declare */
int i;
float
tot_wg=0.0,tot_hr=0.0,tot_ot=0.0,tot_grs=0.0;
float
max_wg=0.0,max_hr=0.0,max_ot=0.0,max_grs=0.0;
float min_wg,min_hr,min_ot,min_grs;
/* insert initial values */
strcpy(emp->name,"Connie
Cobol");
emp->id_number=98401;
emp->wage=10.60;
/* increment pointer vale for next
address location */
emp++;
strcpy(emp->name,"Marry
Apl");
emp->id_number=526488;
emp->wage=9.75;
/* increment pointer vale for next
address location */
emp++;
strcpy(emp->name,"Frank
Fortran");
emp->id_number=765349;
emp->wage=10.50;
/* increment pointer vale for next
address location */
emp++;
strcpy(emp->name,"Jeff
Ada");
emp->id_number=34645;
emp->wage=12.25;
/* increment pointer vale for next
address location */
emp++;
strcpy(emp->name,"Anton
Pascal");
emp->id_number=127615;
emp->wage=10.00;
/* point emp points the first element groups */
emp=e;
/* console input hours and claculate wages*/
for(i=0;i<5;i++)
{
printf("Enter the hours for %d the
employee : ",(i+1));
scanf("%f",&emp->hours);
if(emp->hours>40)
{
emp->overtime=(emp->hours-40) ;
/* 1.5 is over time pay factor
*/
emp->gross=(40*emp->wage +
emp->overtime*1.5*emp->wage);
}
else
{
emp->overtime=0;
emp->gross=(emp->hours*emp->wage +
emp->overtime*1.5*emp->wage);
}
/* increment pointer vale for next address location
*/
emp++;
}
/* point emp points the first element groups */
emp=e;
/* print details */
printf("\n-------------------------------------------------------------------------\n");
printf("Name Clock# Wage Hours OT Gross\n");
printf("\n-------------------------------------------------------------------------\n");
for(i=0;i<5;i++)
{
printf("%s\t %6li\t %.2f\t %.2f\t %.2f\t
%.2f\n",emp->name,emp->id_number,emp->wage,emp->hours,emp->overtime,emp->gross);
/* increment pointer vale for next address location
*/
emp++;
}
printf("\n-------------------------------------------------------------------------\n");
emp=e;
for(i=0;i<5;i++)
{
tot_wg=tot_wg+emp->wage;
tot_hr=tot_hr+emp->hours;
tot_ot=tot_ot+emp->overtime;
tot_grs=tot_grs+emp->gross;
/* increment pointer vale for next
address location */
emp++;
}
/* point emp points the first element groups */
emp=e;
/* print toatl and average */
printf("\nTotal: %0.2f %0.2f %0.2f
%0.2f\n",tot_wg,tot_hr,tot_ot,tot_grs);
emp=e;
printf("Average: %0.2f %0.2f %0.2f
%0.2f\n",tot_wg/5,tot_hr/5,tot_ot/5,tot_grs/5);
/* point emp points the first element groups
*/
emp=e;
/* calculate maximum values */
for(i=0;i<5;i++)
{
if(emp->wage>max_wg)
{
max_wg=emp->wage;
}
if(emp->hours>max_hr)
{
max_hr=emp->hours;
}
if(emp->overtime>max_ot)
{
max_ot=emp->overtime;
}
if(emp->gross>max_grs)
{
max_grs=emp->gross;
}
/* increment pointer vale for next address location
*/
emp++;
}
/* point emp points the first element groups */
emp=e;
/* calculate minimum values */
min_wg=emp->wage;
min_hr=emp->hours;
min_ot=emp->overtime;
min_grs=emp->gross;
emp=e;
for(i=0;i<5;i++)
{
if(emp->wage<min_wg)
{
min_wg=emp->wage;
}
if(emp->hours<min_hr)
{
min_hr=emp->hours;
}
if(emp->overtime<min_ot)
{
min_ot=emp->overtime;
}
if(emp->gross<min_grs)
{
min_grs=emp->gross;
}
/* increment pointer vale for next address location
*/
emp++;
}
/* point emp points the first element groups */
emp=e;
/* print max and minimum value */
printf("Minimum: %0.2f %0.2f %0.2f
%0.2f\n",min_wg,min_hr,min_ot, min_grs);
emp=e;
printf("Maximum: %0.2f %0.2f %0.2f
%0.2f\n",max_wg,max_hr,max_ot, max_grs);
}
SCREEN SHOT
OUTPUT
Please include function in this program Write a C program that will calculate the gross pay...
Write a C program that will calculate the gross pay of a set of employees. The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. The program determines the overtime hours (anything over 40 hours), the gross pay and then outputs a table in the following format. Column alignment, leading zeros in Clock#, and zero suppression in float fields is important. Use 1.5 as the overtime pay...