//********************************************************
//
// Assignment 5 - Functions
//
// Name: Raissa Almeida Beckenkamp
//
// Class: C Programming, Fall 2025
//
// Date: October 12,2025
//
// Description: Program which determines overtime and
// gross pay for a set of employees with outputs sent
// to standard output (the screen).
//
// All functions called by reference
//
//********************************************************
#include <stdio.h>
// constants
#define SIZE 5
#define OVERTIME_RATE 1.5f
#define STD_WORK_WEEK 40.0f
// function prototypes
void getHours (long int clockNumber[], float hours[], int theSize);
void printHeader (void);
void printEmp (long int clockNumber[], float wageRate[], float hours[],
float overtimeHrs[], float grossPay[], int theSize);
// TODO: Add other function prototypes here as needed
float calcOT (float hours);
float calcGross (float wageRate,
float hours,
float overtimeHrs);
int main()
{
// Variable Declarations
long int clockNumber[SIZE] = {98401,526488,765349,34645,127615}; // ID
float grossPay[SIZE]; // gross pay
float hours[SIZE]; // hours worked in a given week
int i; // loop and array index
float overtimeHrs[SIZE]; // overtime hours
float wageRate[SIZE] = {10.60,9.75,10.50,12.25,8.35}; // hourly wage rate
// Read in the hours worked for each employee
getHours (clockNumber, hours, SIZE);
// TODO: Function call to calculate overtime hours
overtimeHrs[i] = calcOT(hours[i]);
// TODO: Function call to calculate gross pay
grossPay[i] = calcGross(hours[i], wageRate[i]);
// Print the initial table header
printHeader ();
// Function call to output results to the screen
printEmp (clockNumber, wageRate, hours,
overtimeHrs, grossPay, SIZE);
return (0);
} // main
//***************************************************************
// Function: getHours
//
// Purpose: Obtains input from user, the number of hours worked
// per employee and stores the results in an array that is
// passed back to the calling function by reference.
//
// Parameters:
//
// clockNumber - Array of employee clock numbers for each employee
// hours - Array of hours worked by each employee
// theSize - Number of employees to process
//
// Returns: Nothing (call by reference)
//
//**************************************************************
void getHours (long int clockNumber[], float hours[], int theSize)
{
int i; // loop and array index
// Read in hours for each employee
for (i= 0; i < theSize; ++i)
{
printf("\nEnter hours worked by emp # %06li: ", clockNumber
[i
]); }
} // getHours
//**************************************************************
// Function: printHeader
//
// Purpose: Prints the initial table header information.
//
// Parameters: none
//
// Returns: void
//
//**************************************************************
void printHeader (void)
{
printf ("\n\n*** Pay Calculator ***\n");
// print the table header
printf("\nClock# Wage Hours OT Gross\n"); printf("------------------------------------------------\n");
} // printHeader
//**************************************************************
// Function: printEmp
//
// Purpose: Prints out all the employee information in a
// nice and orderly table format.
//
// Parameters:
//
// clockNumber - Array of employee clock numbers
// wageRate - Array of employee wages per hour
// hours - Array of number of hours worked by an employee
// overtimeHrs - Array of overtime hours for each employee
// grossPay - Array of gross pay calculations for each employee
// theSize - Number of employees to process
//
// Returns: Nothing (call by reference)
//
//**************************************************************
void printEmp (long int clockNumber[], float wageRate[], float hours[],
float overtimeHrs[], float grossPay[], int theSize)
{
int i; // loop and array index
// access and print each employee
for (i = 0; i < theSize; ++i)
{
// TODO: add code to print out each employee one at a time
printf("\t%06ld %5.2f %5.1f %5.1f %7.2f\n", clockNumber[i], wageRate[i], hours[i], overtimeHrs[i], grossPay[i]);
} // printEmp
}
// TODO: Add other functions here as needed
// ... remember your comment block headers for each function
//**************************************************************
// Function: calcOT
//
// Purpose: Calculate overtime hours for a given week.
// Overtime is any time worked over STD_WORK_WEEK.
//
// Parameters: hours - total hours worked in a given week
//
// Returns: overtime hours (0 if hours <= STD_WORK_WEEK)
//
//**************************************************************
float calcOT(float hours)
{
if (hours > STD_WORK_WEEK)
{
return (hours - STD_WORK_WEEK);
}
else
{
return 0.0f;
}
}
//**************************************************************
// Function: calcGross
//
// Purpose: Calculate gross pay using regular and overtime hours.
// Regular hours are capped at STD_WORK_WEEK. Overtime
// is paid at OVERTIME_RATE times the hourly wage.
//
// Parameters: hours - total hours worked in a given week
// wage - hourly wage rate
//
// Returns: gross pay for the week
//
//**************************************************************
float calcGross(float hours, float wage)
{
float regHours = hours;
float otHours = 0.0f;
if (hours > STD_WORK_WEEK)
{
otHours = hours - STD_WORK_WEEK;
regHours = STD_WORK_WEEK;
}
return (regHours * wage) + (otHours * wage * OVERTIME_RATE);
}