//*******************************************************
//
// Assignment 4 - Arrays
//
// Name: Marin Haxhiaj
//
// Class: C Programming, Spring 2025
//
// Date: 02/20/2025
//
// Description: Program which determines overtime and 
// gross pay for a set of employees with outputs sent 
// to standard output (the screen).
//
//********************************************************

#include <stdio.h>


#define SIZE 5           // Number of employees to process
#define STD_HOURS 40.0   // Standard work week hours before overtime
#define OT_RATE 1.5      // Overtime pay factor

int main() {

	// Declare variables needed for the program
    // Recommend an array for clock, wage, hours,
    // ... and overtime hours and gross.
    // Recommend arrays also for normal pay and overtime pay                
    // It is OK to pre-fill clock and wage values ... or you can prompt for them

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

    float wageRate[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};          //hourly pay
    float hours[SIZE];
    float overtimeHrs[SIZE];
    float normalPay[SIZE];
    float overtimePay[SIZE];
    float grossPay[SIZE];
    int i;

    float totalHours = 0, totalOvertimeHrs = 0, totalOvertimePay = 0, totalGrossPay = 0;

    printf("\n**************************************\n");
    printf("*           Pay Calculator            *\n");
    printf("**************************************\n\n");     //Table Header

    for (i = 0; i < SIZE; i++) {
        scanf("%f", &hours[i]);
    }

    for (i = 0; i < SIZE; i++) {
        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;
            normalPay[i] = hours[i] * wageRate[i];
            overtimePay[i] = 0;
        }
        grossPay[i] = normalPay[i] + overtimePay[i];
        
        totalHours += hours[i];
        totalOvertimeHrs += overtimeHrs[i];
        totalOvertimePay += overtimePay[i];
        totalGrossPay += grossPay[i];
    }

    printf("\n%-10s %-10s %-10s %-10s %-10s %-10s\n", "Clock#", "Wage", "Hours", "OT Hours", "OT Pay", "Gross Pay");
    printf("-------------------------------------------------------------------------------\n");
    
    for (i = 0; i < SIZE; i++) {
        printf("%06ld   $%7.2f   %7.2f   %7.2f   $%7.2f   $%7.2f\n",
               clockNumber[i], wageRate[i], hours[i], overtimeHrs[i], overtimePay[i], grossPay[i]);
    }
    
    printf("-------------------------------------------------------------------------------\n");
    printf("%-10s %-10s %7.2f   %7.2f   $%7.2f   $%7.2f\n", "TOTALS", "", totalHours, totalOvertimeHrs, totalOvertimePay, totalGrossPay);

    return 0;
}