//*******************************************************
//
// Homework: 3
//
// Name: Blake Shetler
//
// Class: C Programming, Fall 2024
//
// Date: 09/29/2024
//
// Description: Program which determines gross pay
// and outputs are sent to standard output (the screen).
//
// Non file pointer solution
//
//********************************************************
#include <stdio.h>
//declare constants
#define STD_HOURS 40.0 // 40 hours worked per week is standard
#define QUANTITY 5 // 5 employees will be processed in this program
#define OT_DIFF 1.5 // OT differential is normal pay rate times 1.5
int main()
{
//declare variables
int clock_number; // employee's ID or clock number
float wage_rate; // employee's hourly rate
float hours_worked; // number of hours employee worked for that week
float gross_pay; // employee's gross pay for the given week
float reg_pay; // regular hourly rate
float overtime_pay; // pay rate for overtime hours
int idx; // index to be used for loop
//print program header
printf("\t ~~~~~~~~ Pay Calulator ~~~~~~~~\n");
//Loop to prompt user to enter clock number, hourly wage, and hours worked for each employee
{
for (idx = 0; idx < QUANTITY; ++idx)
{
printf("\nEnter employee's clock number: \n"); //enter clock number
scanf("%d", &clock_number);
printf("Enter hourly wage for employee: \n"); //enter hourly rate
scanf("%f", &wage_rate);
printf("Enter the number of hours the employee worked this week: \n"); //enter hours
scanf("%f", &hours_worked);
//calucation for gross pay
if (hours_worked <= STD_HOURS) //if employee worked standard or less hours
{
gross_pay = wage_rate * hours_worked; //gross pay will be calculated normally
}
else //otherwise, employee worked overtime
{
overtime_pay = (hours_worked - STD_HOURS) * wage_rate * OT_DIFF;
reg_pay = (STD_HOURS * wage_rate);
gross_pay = overtime_pay + reg_pay; // gross pay will be OT pay plus regular pay
}
//printing out results
printf("\n\t=========================\n");
printf("\tClock# Wage Hours Gross\n");
printf("\t=========================\n");
printf("\t%06i %.2f % 2.1f % 6.2f \n", clock_number, wage_rate,
hours_worked, gross_pay);
} // end of the loop
}
return(0);
} //end of main function