//*******************************************************
//
// Assignment 3 - Conditionals
//
// Name: Barbara Chop
//
// Class: C Programming, Spring 2025
//
// Date: 09/26/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>
// Declare constants
#define STD_HOURS 40.0 // Standard number of hours in a work week
#define NUM_EMPLOYEES 5 // Number of employees to process
#define OT_MULTIPLIER 1.5 // Overtime pay multiplier (time and a half)
int main()
{
int clockNumber; // Employee clock number
float grossPay; // The weekly gross pay (regPay + overtimePay)
float hours; // Total hours worked in a week
float regPay; // Standard weekly pay (40 hours)
float overtimeHrs; // Overtime hours worked beyond STD_HOURS (40hrs)
float overtimePay; // Additional pay based on overtime hours worked
float wageRate; // Hourly wage for an employee
printf ("\n*** Pay Calculator ***");
// Process each employee
for (int i = 0; i < NUM_EMPLOYEES; i++) {
// Prompt the user for the clock number
printf("\n\nEnter clock number: "); scanf("%d", &clockNumber
);
// Prompt the user for the wage rate
// Prompt the user for the number of hours worked
printf("Enter number of hours worked: ");
// Initialize pay variables
regPay = 0;
overtimeHrs = 0;
overtimePay = 0;
grossPay = 0;
// Calculate the overtime hours, normal pay, and overtime pay
if (hours > STD_HOURS) {
overtimeHrs = hours - STD_HOURS; // Hours above standard (40h)
regPay = wageRate * STD_HOURS; // Pay for 40h
overtimePay = (OT_MULTIPLIER * wageRate) * overtimeHrs; // Overtime payment calculation
} else {
overtimeHrs = 0; // No overtime worked
regPay = wageRate * hours; // hours payment calculation
overtimePay = 0; // No overtime payment
}
// Calculate the gross pay
grossPay = regPay + overtimePay;
// Print out employee information
printf("\n\nClock# Wage Hours OT Gross\n"); printf("-----------------------------------------\n"); printf("%06d %7.2f %6.1f %5.1f %9.2f\n", clockNumber, wageRate, hours, overtimeHrs, grossPay);
}
return 0;
}