//*******************************************************
//
// Homework: 3
//
// Name: Matt Smith
//
// Class: C Programming, Spring 2025
//
// Date: 2/14/2025
//
// Description: Write a C program that will calculate the
// overtime hours and gross pay of a set of
// employees given the number of hours they
// they worked in a given week.
//
//********************************************************
#include <stdio.h>
// Declare constants
#define STD_HOURS 40.0
#define NUM_EMPLOYEES 5
// TODO: Declare and use at least one more constant
#define OT_RATE 1.5
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; // Overtime hours counted over 40 a week
float overtimePay; // Any hours worked past the normal scheduled work week
float wageRate; // Hourly wage for an employee
printf ("*** Pay Calculator ***\n");
// 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 then umber of hours worked
printf("\nEnter number of hours worked: ");
if (hours > STD_HOURS) {
// TODO: add states as needed to if body
// TODO: calculate the three new variables with overtime
normalPay = hours * wageRate;
overtimeHrs = hours - STD_HOURS;
overtimePay = (OT_RATE * wageRate) * overtimeHrs;
}
else
{
// TODO: add states as needed to else body
// TODO: calculate the three new variables without overtime
normalPay = hours * wageRate;
overtimeHrs = 0.0;
overtimePay = 0.0;
}
// Calculate the gross pay with normal pay and any additional overtime pay
grossPay = normalPay + overtimePay;
// Print out information on the current employee
// Optional TODO: Feel free to also print out normalPay and overtimePay
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);
}//for
return 0;
}//main