//*******************************************************
//
// Assignment 3 - Conditionals
//
// Name: Sean Ryder
//
// Class: C Programming, Fall 2023
//
// Date: 30 September 2023
//
// 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 // The standard hours of work
#define NUM_EMPLOYEES 5 // The number of employees to process
#define OT_RATE 1.5 // The overtime rate
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: ");
// Calculate the overtime hours, normal pay, and overtime pay
if (hours > STD_HOURS) {
overtimeHrs = ( hours - STD_HOURS );
overtimePay = ( OT_RATE * wageRate ) * overtimeHrs;
normalPay = ( STD_HOURS * wageRate );
} else {
overtimeHrs = (0.0);
overtimePay = (0.0);
normalPay = ( hours * wageRate );
}
// 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 Normal Pay OT Pay Gross\n"); printf("-------------------------------------------------------------\n"); printf("%06d $%5.2f %4.1f %5.1f $%7.2f $%7.2f $%8.2f\n", clockNumber, wageRate, hours, overtimeHrs, normalPay, overtimePay, grossPay);
}
return 0;
}