/******************************************************
 *
 * Assignment 4 - Arrays
 *
 * Name: Robert Hyde
 *
 * Class: C Programming, Fall 2026
 *
 * Date: September 28, 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          /* number of employees to process */
#define STD_HOURS 40.0  /* normal work week hours */
#define OT_RATE 1.5     /* time and a half overtime setting */

int main()
{
    /* Declare variables needed for the program */

    /* Unique employee identifier */
    long int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615};

    /* Hourly pay for each employee */
    float wageRate[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};

    /* Arrays for employee information and calculations */
    float hours[SIZE];
    float overtimeHrs[SIZE];
    float normalPay[SIZE];
    float overtimePay[SIZE];
    float grossPay[SIZE];

    int i;

    printf("\n*** Pay Calculator ***\n\n");

    /* Process each employee one at a time */
    for (i = 0; i < SIZE; i++)
    {
        /* Prompt for and read hours worked */
        printf("Enter hours worked for employee %ld: ", clockNumber[i]);
        scanf("%f", &hours[i]);

        /* Calculate overtime and gross pay */
        if (hours[i] > STD_HOURS)
        {
            overtimeHrs[i] = hours[i] - STD_HOURS;

            normalPay[i] = STD_HOURS * wageRate[i];

            overtimePay[i] = overtimeHrs[i] * wageRate[i] * OT_RATE;
        }
        else
        {
            overtimeHrs[i] = 0.0;

            normalPay[i] = hours[i] * wageRate[i];

            overtimePay[i] = 0.0;
        }

        /* Calculate gross pay */
        grossPay[i] = normalPay[i] + overtimePay[i];
    }

    /* Print table header */
    printf("\n--------------------------------------------------------------------------\n");
    printf("    Clock#   Wage  Hours    OT       Gross\n");
    printf("--------------------------------------------------------------------------\n");

    /* Print employee information */
    for (i = 0; i < SIZE; i++)
    {
        printf("    %06ld  %5.2f  %5.1f   %5.1f    %8.2f\n",
               clockNumber[i],
               wageRate[i],
               hours[i],
               overtimeHrs[i],
               grossPay[i]);
    }

    printf("--------------------------------------------------------------------------\n");

    return 0;
}