//*******************************************************
//
// Assignment 3 - Conditionals
//
// Name: Kamil Kurpiewski
//
// Class: C Programming, Fall, 2025
//
// Date: 9/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
#define NUM_EMPLOYEES 5
// TODO: Declare and use one more constant
// New Constant
#define SIZE 5
// Calculating overtime function
float calculate_overtime_hours(float hours){
if (hours > STD_HOURS) {
return hours - STD_HOURS;
} else {
return 0;
}
}
//Gross Pay Function
float calculate_gross_pay(float wage_rate, float hours) {
float normal_pay, overtime_hours, overtime_pay;
overtime_hours = calculate_overtime_hours(hours);
if (hours > STD_HOURS) {
normal_pay = wage_rate * STD_HOURS;
overtime_pay = overtime_hours * wage_rate * 1.5;
} else {
normal_pay = wage_rate * hours;
overtime_pay = 0;
}
return normal_pay + overtime_pay;
}
int main()
{
int clockNumber; // Employee clock number
float grossPay; // The weekly gross pay which is the normalPay + any overtimePay
float hours; // Total hours worked in a week
float normalPay; // Standard weekly normal pay without overtime
float overtimeHrs; // Any hours worked past the normal scheduled work week
float overtimePay; // Additional overtime pay for any 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
printf("\nEnter wage rate: ");
// Prompt the user for the number of hours worked
printf("\nEnter number of hours worked: ");
// Using new funtion calculate gross pay
grossPay = calculate_gross_pay(wageRate, hours);
//Overtime hours
float overtimeHrs = calculate_overtime_hours(hours);
// Print out information on the current employee
printf("\n\nClock# Wage Hours OT Gross\n"); printf("------------------------------------------------\n"); printf("%06d %5.2f %5.1f %5.1f %8.2f\n", clockNumber, wageRate, hours, overtimeHrs, grossPay);
}
return 0;
}