//*******************************************************
//
// Assignment 3 - Conditionals
//
// Name: Ryan Harwick
//
// Class: C Programming, Fall 2024
//
// Date: 09/26/2024
//
// 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_PERCENT 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; // 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 \n Enter clock number: " ) ; scanf ( "%d" , & clockNumber
) ;
// Prompt the user for the wage rate
printf ( "\n Enter wage rate: " ) ;
// Prompt the user for the number of hours worked
printf ( "\n Enter number of hours worked: " ) ;
// Calculate the overtime hours, normal pay, and overtime pay
if ( hours > STD_HOURS) {
normalPay = wageRate * hours;
overtimeHrs = hours - STD_HOURS;
overtimePay = overtimeHrs * ( wageRate * OVERTIME_PERCENT) ;
} else {
overtimePay = 0 ;
}
// Calculate the gross pay with normal pay and any additional overtime pay
grossPay = normalPay + overtimePay;
// Print out information on the current employee
if ( hours > STD_HOURS) {
printf ( "\n \n Clock#| Wage| Hours| OT| Gross Pay| Normal Pay| Overtime Pay|\n " ) ; printf ( "------------------------------------------------\n " ) ; printf ( "%06d %5.2f %5.1f %5.1f %8.2f %8.2f %8.2f\n " , clockNumber, wageRate, hours, overtimeHrs, grossPay, normalPay, overtimePay) ;
} else {
printf ( "\n \n Clock#| Wage| Hours| OT| Gross|\n " ) ; printf ( "------------------------------------------------\n " ) ; printf ( "%06d %5.2f %5.1f %5.1f %8.2f\n " , clockNumber, wageRate, hours, overtimeHrs, grossPay) ;
}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