Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program that will calculate the gross pay of a set of employees. Continue to use all the features from your past assignments.

Write a C program that will calculate the gross pay of a set of employees. Continue to use all the features from your past assignments. In particular, expand upon your previous assignment and continue to use multiple functions to help with various tasks called upon by your program. The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. The program determines the overtime hours (anything over 40 hours), the gross pay, and then outputs a table in the following format. Column alignment, leading zeros in Clock#, and zero suppression in float fields is important. Use 1.5 as the overtime pay factor. -------------------------------------------------------------------------- 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 You should implement this program using the following structure to store the information for each employee. /* This is the structure you will need, feel free to modify as needed */ struct employee { long int id_number; /* or just int id_number; */ float wage; float hours; float overtime; float gross; }; In your main function, define an array of structures, and feel free to initialize the clock and wage values in your array declaration. You must prompt for each employee's hours and calculate their corresponding overtime and gross pay. Use the following information to initialize your data. 98401 10.60 526488 9.75 765349 10.50 34645 12.25 127615 8.35 Create an array of structures with 5 elements, each being of type struct employee. Initialize the array with the data provided and reference the elements of the array with the appropriate subscripts. Like the previous homework, use multiple functions in your answer and continue to use constants as needed. The only array you need is the array of structures, you don't need to create a separate array for clock, wage, hours, overtime, and gross. You can either pass the entire array of structures to each function, or pass values that work on one array element (and its associated structure members) at a time ... either will work. Templates have been provided this week if you would like to use them. As always, the templates are simply suggestions to help you get started. Feel free to improvise and seek out your own design and solutions as long as they meet the requirements specified in the assignment. Whatever way you do it, don't use global variables (unless for file pointers should you decide to utilize them) ... I don't want all your functions looking like: void foo () ... with no parameters passed or values returned. There are benefits and drawbacks to each of my provided code template approaches. Good luck with these templates, or feel free to create your own from scratch.

/*Define and Includes */

#include

/* Define Constants */ #define NUM_EMPL 5

/* Define a global structure to pass employee data between functions */ /* Note that the structure type is global, but you don't want a variable */ /* of that type to be global. Best to declare a variable of that type */ /* in a function like main or another function and pass as needed. */

struct employee { long id_number; float wage; float hours; float overtime; float gross; };

/* define prototypes here for each function except main */

void Output_Results_Screen (struct employee emp [ ], int size);

/* add your functions here */

/******************************************************************** ** Function: Output_Results_Screen ** ** Purpose: Outputs to screen in a table format the following ** information about an employee: Clock, Wage, ** Hours, Overtime, and Gross Pay. ** ** Parameters: ** ** employeeData - an array of structures containing ** employee information ** size - number of employees to process ** ** Returns: Nothing (void) ** ********************************************************************/

void Output_Results_Screen ( struct employee employeeData[], int size ) { int i; /* loop index */

/* print information about each employee */ for (i = 0; i < size ; ++i) { printf(" %06li %5.2f %4.1f %4.1f %8.2f ", employeeData[i].id_number, employeeData[i].wage, employeeData[i].hours, employeeData[i].overtime, employeeData[i].gross); } /* for */

} /* Output_results_screen */

int main () { /* Set up a local variable and initialize the clock and wages of my employees */ struct employee employeeData[NUM_EMPL] = { { 98401, 10.60 }, { 526488, 9.75 }, { 765349, 10.50 }, { 34645, 12.25 }, { 127615, 8.35 } };

/* Call various functions needed to read and calculate info */

/* Print the column headers */

/* Function call to output results to the screen in table format. */ Output_Results_Screen (employeeData, NUM_EMPL);

return(0); /* success */

} /* main */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions