/************************************************************************/
/* */
/* HOMEWORK: 8 */
/* */
/* Name: Matthew Tracy */
/* */
/* Class: C Programming, Cybercourse Spring 2026 */
/* */
/* Date: <04/03/2026> */
/* */
/* Description: Program which determines gross pay based on overtime */
/* and outputs a formatted answer. Employee information */
/* is stored in an array of structures and referenced */
/* through the use of pointers. */
/************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/* define all constants here */
#define SIZE 5
/* type to hold employee information */
struct employee
{
char name [20]; /* Employee first and last name */
int id; /* unique employee identifier */
float wage; /* hourly wage rate */
float hours; /* hours worked in a given week */
float overtime; /* hours worked after the standard work week */
float gross; /* total gross pay, standard pay + overtime pay */
};
/* add function prototypes here if you wish */
/* Remember to add function comment header block for each function */
/* like shown below for printData, a hint for getHours is below. */
float getHours ( int id )
{
float hours; /* hours worked for the employee */
/* prompt with id to read in a value for hours */
return (hours);
}
/************************************************************************/
/* Function: printData */
/* */
/* Purpose: Outputs to screen in a table format the following: */
/* - Employee First and Last Name */
/* - Employee clock number */
/* - Wage rate for an employee. */
/* - Total hours worked by employee. */
/* - Overtime Hours. */
/* - Gross Pay. */
/* */
/* Parameters: emp_ptr - pointer to array of structures */
/* size - number of employees to process */
/* */
/* Returns: Nothing, since emp_ptr is passed by reference */
/************************************************************************/
void printData ( struct employee * emp_ptr, int size )
{
int n; /* counter used in for loop to keep track of iterations */
/* prints the output for all employees to the screen */
for (n = 0; n < SIZE; n++)
{
printf ("%-20.20s %06i $%5.2f %4.1f %4.1f $%7.2f \n",
emp_ptr->name,
emp_ptr->id,
emp_ptr->wage,
emp_ptr->hours,
emp_ptr->overtime,
emp_ptr->gross);
++emp_ptr; /* move to next employee */
}
printf ("\n");
}
/************************************************************************/
/* Function: Main */
/************************************************************************/
int main()
{
/* A structure array to hold information on employees */
struct employee emp [SIZE] = { {"Connie Cobol", 98401, 10.60},
{"Frank Fortran", 526488, 9.75},
{"Mary Apl", 765349, 10.50},
{"Jeff Ada", 34645, 12.25},
{"Anton Pascal", 127615, 10.0}
};
int i; /* loop and array index */
struct employee * emp_ptr; /* pointer to an employee structure */
emp_ptr = emp; /* point to beginning of emp array */
/* Read in hours, and calculate overtime and gross */
for (i=0; i < SIZE; ++i)
{
/* Get user input for the hours worked for each employee */
emp_ptr->hours = getHours ( emp_ptr->id );
/* Calculate overtime for each employee */
/* Calculate gross pay for each employee */
} /* end for */
/* Print column headers to the screen */
/* Print employee data to the screen */
printData ( emp, SIZE );
return 0;
}