//*******************************************************
//
// Assignment 4 - Arrays
//
// Name: Samuel Morris
//
// Class: C Programming, Summer 2025
//
// Date: 07/01/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 constants */
#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() {
// employee data
long int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615};
float wageRate[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};
//
float hours[SIZE]; // hours worked in a given week
float overtimeHrs[SIZE]; // overtime hours worked in a given week
float normalPay[SIZE]; // normal weekly pay without any overtime
float overtimePay[SIZE]; // overtime pay for a given week
float grossPay[SIZE]; // weekly gross pay - normal pay + overtime
int i; // loop and array index
printf("*** Pay Calculator ***\n\n");
// Input and calculation loop
for (i = 0; i < SIZE; i++) {
scanf("%f", &hours
[i
]); // TODO - Prompt and Read in hours worked for employee
// Calculate overtime and gross pay for employee
if (hours[i] >= STD_HOURS) {
overtimeHrs[i] = hours[i] - STD_HOURS;// TODO: Calculate arrays normalPay and overtimePay with
normalPay[i] = STD_HOURS * wageRate[i];
overtimePay[i] = overtimeHrs[i] * wageRate[i] * OT_RATE;
} else {
overtimeHrs[i] = 0.0; // TODO: Calculate arrays normalPay and overtimePay without
normalPay[i] = hours[i] * wageRate[i];
overtimePay[i] = 0.0;
}
// Calculate gross pay
grossPay[i] = normalPay[i] + overtimePay[i];
}
// Output
// TODO: 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++) {
// TODO: Print employee information from your arrays
printf(" %06ld %5.2f %5.1f %6.1f %8.2f\n", clockNumber[i],
wageRate[i],
hours[i],
overtimeHrs[i],
grossPay[i]);
}
return 0;
}