Write a C program that will calculate the gross pay and overtime hours for a set
ID: 3550218 • Letter: W
Question
Write a C program that will calculate the gross pay and overtime hours for a set of employees using arrays.
The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. You do not need to prompt for how many employees to proccess up front. Instead, define a constant and use it for your array size and within your code (such as loop tests), for example:
#define SIZE 5
Make sure you continue to use other constants as well.
You can also initialize the clock and wage arrays to the 5 test values.
long int clockNumber [SIZE] = {98401, 526488, 765349, 34645, 127615}; /* employee ID */
float hourlyWage [SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35}; /* hourly wage */
The program determines the overtime hours (anything over 40 hours), the gross pay and then outputs a table in the following format.
----------------------------------------------
Clock# Wage Hours OT Gross
----------------------------------------------
098401 10.60 51.0 11.0 598.90
526488 9.75 42.5 2.5 426.56
765349 10.50 37.0 0.0 388.50
034645 12.25 45.0 5.0 581.88
127615 8.35 0.0 0.0 0.00
Column alignment, leading zeros in Clock#, and zero suppression in float fields are important. Use time and a half (1.5) as the overtime pay factor (which should be defined as a constant).
Continue to work with other constants and features that you used in the previous homework assignments.
You should implement this program using one array for clock number, one array for wages, and one for hours. You can optionally create arrays for overtime and gross values as well (I would recommend that you do).
Use the following information to initialize your clock number and wage rate arrays in the program. Only hours worked will be read in from the terminal. Overtime and Gross Pay will be calculated based on the hours inputted for each employee.
98401 10.60
526488 9.75
765349 10.50
34645 12.25
127615 8.35
Use the following information to run your program (you can implement your prompting for hours anyway you wish ... this is just a suggestion).
For Enter
Clock Hours
------ -----
98401 51.0
526488 42.5
765349 37.0
34645 45.0
127615 0.0
Please use this template:
/* Add File Header */
#include <stdio.h>
/* constants to use */
#define SIZE 5 /* employees to process */
/* add other constants here ... */
int main()
{
/* declaring variables needed for program */
/* You'll need an array for clock, wage, hours, */
/* ... and overtime and gross. */
/* Its OK to pre-fill clock and wage values */
/* ... or you can prompt for them. */
long int clock_number [SIZE] = {98401, 526488, 765349, 34645, 127615}; /* form of worker identification */
int count; /* loop index */
float hourly_pay [SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35}; /* money earned per hour of work */
/* Process each employee one at a time */
for (count = 0; count < SIZE; count++)
{
/* Read in hours worked for employee */
/* calculate overtime and gross pay for employee */
}
/* output the data in a table type format */
/* Print a nice table header */
/* Access each employee and print */
for(count = 0; count < SIZE; count++)
{
/* print employee information from your arrays */
}
return(0);
}
Explanation / Answer
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.