#include <stdio.h>
// Declare constants
#define STD_HOURS 40.0
#define NUM_EMPLOYEES 5
#define OVERTIME_RATE 1.5
// TODO: Declare and use at least one more constant
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 worked beyond a normal week (40 hours)
float overtimePay; // Any hours worked past the normal scheduled work week
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: " ) ;
// Optional TODO: Remove these initialization statements if desired
// initialize so initial template prints these both as zero
//grossPay = 0;
//overtimeHours = 0;
// Calculate the overtime hours, normal pay, and overtime pay
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
// Optional TODO: Feel free to also print out normalPay and overtimePay
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) ;
}
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBEZWNsYXJlIGNvbnN0YW50cyAKI2RlZmluZSBTVERfSE9VUlMgNDAuMAojZGVmaW5lIE5VTV9FTVBMT1lFRVMgNQojZGVmaW5lIE9WRVJUSU1FX1JBVEUgMS41IAoKLy8gVE9ETzogIERlY2x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