//*******************************************************
//
// Assignment 4 - Arrays
//
// Name: Elimelech Wolvovsky
//
// Class: C Programming, Spring 2026
//
// Date: 2/19/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 before overtime
#define OT_RATE 1.5 // time and half overtime setting
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 grossPay [SIZE]; // weekly gross pay - normal pay + overtime pay
float hours [SIZE]; // hours worked in a given week
int i; // loop and array index
float normalPay [SIZE]; // normal weekly pay without any overtime
float overtimeHrs[SIZE]; // overtime hours worked in a given week
float overtimePay [SIZE]; // overtime pay for a given week
// hourly pay for each employee
float wageRate [SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};
printf ("\n*** Pay Calculator ***\n\n");
// Process each employee one at a time
for (i = 0; i < SIZE; i++)
{
// Prompt and Read in hours worked for employee
printf("\nEnter number of hours worked: ");
// 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] * OT_RATE;
}
else // no OT
{
overtimeHrs[i] = 0;
normalPay[i] = hours[i] * wageRate[i];
overtimePay[i] = 0;
}
// Calculate Gross Pay
grossPay[i] = normalPay[i] + overtimePay[i];
}
// Print a nice table header
printf("\n\nClock# Wage Hours OT Normal pay Overtime pay Gross\n"); printf("-----------------------------------------------------------------------\n");
// Now that we have all the information in our arrays, we can
// Access each employee and print to screen or file
for (i = 0; i < SIZE; i++)
{
// Print employee information from your arrays
printf("%06d %5.2f %5.1f %5.1f %11.2f %11.2f %11.2f\n", clockNumber[i], wageRate[i], hours[i], overtimeHrs[i], normalPay[i], overtimePay[i], grossPay[i]);
}
//Optiona challenge:
//define variables to calculate total sum, and average
float totalWageRate = 0;
float totalHours = 0;
float totalOverTimeHrs = 0;
float totalNormalPay = 0;
float totalOvertimePay = 0;
float totalGrossPay = 0;
//Loop through arrays to gather the sum
for (i = 0; i < SIZE; i++)
{
totalWageRate += wageRate[i];
totalHours += hours[i];
totalOverTimeHrs += overtimeHrs[i];
totalNormalPay += normalPay[i];
totalOvertimePay += overtimePay[i];
totalGrossPay += grossPay[i];
}
// Print divider
printf("-----------------------------------------------------------------------\n");
//Print totals
printf("Total %5.2f %5.1f %5.1f %11.2f %11.2f %11.2f\n", totalWageRate, totalHours, totalOverTimeHrs, totalNormalPay, totalOvertimePay, totalGrossPay);
printf("Average %5.2f %5.1f %5.1f %11.2f %11.2f %11.2f\n", totalWageRate / SIZE, totalHours / SIZE, totalOverTimeHrs / SIZE, totalNormalPay / SIZE, totalOvertimePay / SIZE, totalGrossPay / SIZE);
return(0);
}