//*******************************************************
//
// Assignment 3 - Conditionals
//
// Name: Brian Fallon
//
// Class: C Programming, Spring 2025
//
// Date: February 11, 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
#define OT_HOURS >40.0
int main()
{
int clockNumber; // Employee clock number
float grossPay; // The weekly gross pay which is the normalPay + any overtimePay
float hoursTotal; // 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: "); scanf("%f", &hoursTotal
);
// Optional TODO: Remove these two statements if desired
// ... were added just for the template to print some values out of the box
grossPay = 0;
overtimeHrs = 0;
// Calculate the overtime hours, normal pay, and overtime pay
if (hoursTotal > STD_HOURS)
{
overtimeHrs = hoursTotal - STD_HOURS; // TODO: calculate the three values with overtime
} //End if
else
{
normalPay = hoursTotal * wageRate; // TODO: calculate the two values without overtime
} //End else
// Calculate the gross pay with normal pay and any additional overtime pay
overtimePay = overtimeHrs *(1.5*wageRate);
normalPay = wageRate * STD_HOURS;
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, hoursTotal, overtimeHrs, grossPay);
} //End for
return 0;
} //End main