//*******************************************************
//
// Assignment 4 - Arrays
//
// Name: <Azan Butt>
//
// Class: C Programming, <Spring 2025>
//
// Date: <02-19-25>
//
// 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()
{
// unique employee identifier
long int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615}; // Employees clock number
float wageRate[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35}; // hourly pay for each employee
float hours[SIZE]; // Hours worked in a given week
float normalPay[SIZE]; // Normal weekly pay (no overtime)
float overtimeHrs[SIZE]; // Overtime hours worked in a given week
float grossPay[SIZE]; // weekly gross pay - normal pay + overtime pay
float overtimePay[SIZE]; // Overtime pay for a given week
int i; // loop and array index
printf ("\n*** Pay Calculator ***\n\n");
// Process each employee one at a time
for (i = 0; i < SIZE; i++)
{
// complete - Prompt and Read in hours worked for employee
printf("Enter hours worked for Employee %ld: ", clockNumber
[i
]); // Calculate overtime and gross pay for employee
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;
// complete: Calculate arrays normalPay and overtimePay with overtime
}
else // no OT
{
overtimeHrs[i] = 0;
normalPay[i] = hours[i] * wageRate[i];
overtimePay[i] = 0;
// complete: Calculate arrays normalPay and overtimePay without overtime
}
// Calculate Gross Pay
grossPay[i] = normalPay[i] + overtimePay[i];
}
// complete: Print a nice table header
printf("\n-----------------------------------------------------------------------------------------\n"); printf(" Clock# Wage Hours OT 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++)
{
// complete: Print employee information from your arrays
printf("%8ld %5.2f %5.1f %5.1f %8.2f\n", clockNumber
[i
], wageRate
[i
], hours
[i
], overtimeHrs
[i
], grossPay
[i
]);
}
return(0);
}//main