//*******************************************************
//
// Assignment 4 - Arrays
//
// Name: Joshua Lane
//
// Class: C Programming, Fall 2026
//
// Date: 10/01/2026
//
// Description: Program which determines overtime and
// gross pay for a set of employees with outputs sent
// to standard output (the screen).
//
//********************************************************
#include <stdio.h>
// constants to use
#define SIZE 5 // Standard array size
#define STD_HOURS 40.0 // Standard hours worked before OT is met
#define OT_RATE 1.5 // Added pay rate for hours classified as OT
int main()
{
// Establishes an array containing each employees clock number
long int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615};
float grossPay[SIZE]; // Total pay (STD + OT)
float hours[SIZE]; // Total hours worked
int i; // Variable for loops and array calculations
float normalPay[SIZE]; // Pay from standard hourly work only
float overtimeHrs[SIZE]; // Number of OT hours worked
float overtimePay[SIZE]; // Pay from OT hourly work only
// Creates an array containing the hourly pay for each employee
float wageRate[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};
printf("\n*** Pay Calculator ***\n\n");
// Loop to iterate through each employee and calculuate their grossPay
for (i = 0; i < SIZE; i++)
{
// Prompt and read hours worked
printf("Enter hours worked for employee:");
// Calculate overtime and gross pay for each employee created in the earlier array
if (hours[i] > STD_HOURS)
{
overtimeHrs[i] = hours[i] - STD_HOURS; //Calculates # OT hours worked
normalPay[i] = STD_HOURS * wageRate[i]; //Calculates STD work pay
overtimePay[i] = overtimeHrs[i] * wageRate[i] * OT_RATE; //Calculates OT work pay
}
else
{
overtimeHrs[i] = 0; //If <= 40 hrs worked, OT hours must be = 0
normalPay[i] = hours[i] * wageRate[i]; // Pay rate is then std hours * wage only
overtimePay[i] = 0; // No overtime pay needed in this event
}
// Calculate gross pay after normalPay and overtimePay have been stored to
// the arrays for each employee in the earlier loops
grossPay[i] = normalPay[i] + overtimePay[i];
} //End of employee wage data calculations loop
// Prints the table header, makes reading reporting easier
printf("---------------------------------------------------------------\n"); printf("Clock# Wage Hours OT Hours Gross Pay\n"); printf("---------------------------------------------------------------\n");
// Loops through each employee, outputting their wage data
for (i = 0; i < SIZE; ++i)
{
printf("%06d %5.2f %5.1f %8.2f %8.2f\n", clockNumber[i], wageRate[i], hours[i], overtimeHrs[i], grossPay[i]);
} // End employee data output loop
printf("---------------------------------------------------------------\n");
return 0;
}