//******************************************************* 
// 
// Homework: Assignment 4 - Arrays 
// 
// Name: Jessica Theman 
// 
// Class: C Programming, Fall 2025
// 
// Date: October 5, 2025 
// 
// Description: Program which determines overtime and gross 
// pay for a set of employees with outputs sent to standard
// output (the screen) using arrays.
//
// 
//********************************************************

#include <stdio.h>

// Declare constants
#define STD_HOURS 40.0	//Standard hours
#define OVRTM_PAY 1.5	//Overtime pay rate to multiply standard wage by
#define SIZE 5			//Symbolic constant for array size

int main( )
{
	//Unique employee clock number
    long int clockNumber [SIZE] = {98401, 526488, 765349, 34645, 127615};
    
    float grossPay [SIZE];		//The weekly gross pay which is normalPay + any overtimePay
    float hours [SIZE];			//Total hours worked in a week
    int i;						//Loop and array index
    float normalPay [SIZE];		//Standard weekly normal pay without overtime
    float overtimeHrs [SIZE];	//Any hours worked past the normal scheduled work week
    float overtimePay[SIZE];	//Additional overtime pay for any overtime hours worked
  
	//Hourly wage for each employee
    float wageRate [SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};

	printf("\n			***** PAY CALCULATOR *****			\n");

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

        // Calculate overtime and gross pay for employee
        if (hours[i] >= STD_HOURS)
        {
            overtimeHrs[i] = hours[i] - STD_HOURS;
            //Calculate arrays normalPay and overtimePay with overtime
            normalPay[i] = STD_HOURS * wageRate[i];
            overtimePay[i] = overtimeHrs[i] * wageRate[i] * OVRTM_PAY;
        }
        else //No overtime
        {
            overtimeHrs[i] = 0;
            //Calculate arrays normalPay and overtimePay without overtime
            normalPay[i] = hours[i] * wageRate[i];
            overtimePay[i] = 0.0;
        }

        // Calculate Gross Pay
        grossPay[i] = normalPay[i] + overtimePay[i];
    }

    //Table Header
    printf("\n			***** PAYROLL SUMMARY *****			");
    printf("\n-------------------------------------------------\n");
    printf("Clock#    Wage     Hours    OT Hrs		Gross Pay");
    printf("\n-------------------------------------------------\n");

    // Access each employee and print to screen or file
    for (i = 0; i < SIZE; i++)
    {
        //Print employee information from your arrays
        printf("\n%-9li $%-8.2f %-9.1f %-9.1f $%-7.2f",
            clockNumber[i],
            wageRate[i],
            hours[i],
            overtimeHrs[i],
            grossPay[i]
        );
    }
    printf("\n-------------------------------------------------\n");

    return(0);
}