//********************************************************
//
// Assignment 6 - Structures
//
// Name: David Morse
//
// Class: C Programming, Spring 2026
//
// Date: 3/7/2026
//
// Description: Program which determines overtime and
// gross pay for a set of employees with outputs sent
// to standard output (the screen).
//
// Call by reference design
//
//********************************************************
#include <stdio.h>
// Define Constants
#define SIZE 5
#define STD_HOURS 40.0
#define OT_RATE 1.5
struct employee
{
long clockNumber;
float wageRate;
float hours;
float overtimeHrs;
float grossPay;
};
// Function prototypes
void getHours (struct employee employeeData[], int theSize );
void calcOvertime (struct employee employeeData[], int theSize);
void calcGrossPay (struct employee employeeData[], int theSize);
void printHeader (void);
void printEmp (struct employee emp[], int theSize);
int main ()
{
struct employee employeeData [SIZE] = {
{ 98401, 10.60 },
{ 526488, 9.75 },
{ 765349, 10.50 },
{ 34645, 12.25 },
{ 127615, 8.35 }
};
// Get hours worked
getHours(employeeData, SIZE);
// Calculate overtime hours
calcOvertime(employeeData, SIZE);
// Calculate gross pay
calcGrossPay(employeeData, SIZE);
// Print table header
printHeader();
// Print employee data
printEmp(employeeData, SIZE);
return 0;
} // main
//**************************************************************
// Function: getHours
//**************************************************************
void getHours (struct employee employeeData[], int theSize )
{
int i;
for (i = 0; i < theSize; ++i)
{
printf("\nEnter hours worked by emp # %06li: ", employeeData[i].clockNumber);
scanf("%f", &employeeData
[i
].
hours); }
}
//**************************************************************
// Function: calcOvertime
//**************************************************************
void calcOvertime (struct employee employeeData[], int theSize)
{
int i;
for (i = 0; i < theSize; ++i)
{
if (employeeData[i].hours > STD_HOURS)
employeeData[i].overtimeHrs =
employeeData[i].hours - STD_HOURS;
else
employeeData[i].overtimeHrs = 0;
}
}
//**************************************************************
// Function: calcGrossPay
//**************************************************************
void calcGrossPay (struct employee employeeData[], int theSize)
{
int i;
for (i = 0; i < theSize; ++i)
{
if (employeeData[i].hours > STD_HOURS)
{
employeeData[i].grossPay =
(STD_HOURS * employeeData[i].wageRate) +
(employeeData[i].overtimeHrs *
employeeData[i].wageRate * OT_RATE);
}
else
{
employeeData[i].grossPay =
employeeData[i].hours *
employeeData[i].wageRate;
}
}
}
//**************************************************************
// Function: printHeader
//**************************************************************
void printHeader (void)
{
printf ("\n\n*** Pay Calculator ***\n");
printf("\nClock# Wage Hours OT Gross\n"); printf("------------------------------------------------\n");
}
//**************************************************************
// Function: printEmp
//**************************************************************
void printEmp ( struct employee employeeData[], int theSize )
{
int i;
for (i = 0; i < theSize ; ++i)
{
printf("\n %06li %5.2f %4.1f %4.1f %8.2f", employeeData[i].clockNumber,
employeeData[i].wageRate,
employeeData[i].hours,
employeeData[i].overtimeHrs,
employeeData[i].grossPay);
}
}