//*******************************************************
//
// Assignment 3 - Conditionals
//
// Name: Eiddie Katende
//
// Class: C Programming, Fall 2024
// Date: 9/29/24
// 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
#define OVERTIME_RATE 1.5
int main()
{
int clockNumber; // Employee clock number
float grossPay; // The weekly gross pay including overtime
float hours; // Total hours worked in a week
float overtimeHrs; // Overtime hours worked beyond a normal week (40 hours)
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: ");
scanf ("%f", &wageRate);
// Prompt the user for the number of hours worked
printf("\nEnter number of hours worked: ");
scanf ("%f", &hours);
// Calculate the overtime hours
if (hours > STD_HOURS) {
overtimeHrs = hours - STD_HOURS;
}
else {
overtimeHrs = 0.0;
}
// Calculate the gross pay with normal pay and any additional overtime pay
if (overtimeHrs > 0) {
grossPay = (STD_HOURS * wageRate) + (overtimeHrs * wageRate * OVERTIME_RATE);
}
else {
grossPay = hours * wageRate;
}
// 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;
}