I cant make this happen on Ideone

Oct 6th, 2014
Price: $15 USD

Question description


Write a C program using multiple functions that will calculate the gross pay for a set of employees.

See the last lecture note this week for a template you can use if you feel you need something to start with.   However, feel free to implement this assignment that way you see fit, the template is just there if you need it.  There are multiple ways to effectively implement this assignment.  

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 number, 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

Use the following clock and wage information to initialize your data.

  98401  10.60 
  526488  9.75
  765349  10.50
  34645  12.25
  127615  8.35

You should implement this program using one array for clock number, one array for wage rate, etc.

  • Read in the hours worked for each employee
  • Limit your use of global variables - Learn how to pass parameters!
  • You should have at least 3-4 functions designed and implemented in addition to the main function.
  • Remember to use constants and all the other things we have covered up to this assignment
  • Re-read the homework coding standards ... make sure that each local variable is commented in EACH function, and EACH function has a descriptive function comment header
  • Feel free to initialize the clock and wage values into arrays

I would recommend that your clock, wage, hours, overtime, and gross values be stored in individual arrays.  As a challenge, you can have your program prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below.

Do define your array size up front in your variable declaration.   Don't define the array size at run time with a variable.  This strategy does not always work on every C compiler.

Create a separate function whenever possible to break up your program. For instance, you might have a function for obtaining the hours from the user, another function for calculating overtime hours, another for calculating gross pay and another function for producing the output.  At a minimum, you should have a main function and three or more other functions.

Finally, as always, don't use concepts we have not yet covered.


this is the format we need to know

/* Add file comment block here per coding standards with your name */

#include <stdio.h>

/* constants */
#define NUM_EMPL 5
#define OVERTIME_RATE 1.5f
#define STD_WORK_WEEK 40.0f

/* function prototypes */
/* I added one below to get you started */
void getInput (long clock_number[], float hours[], int size);

/* IMPORTANT:  Add other function prototypes here as needed */

int main()

 /* Variable Declarations */

 long  clock_number[NUM_EMPL] = {98401,526488,765349,34645,127615};
 float gross[NUM_EMPL];
 float hours[NUM_EMPL];     float ot[NUM_EMPL]; 
 float wage_rate[NUM_EMPL] = {10.60,9.75,10.50,12.25,8.35};

 /* Function call to get input from user. */     getInput (clock_number, hours, NUM_EMPL); 

   /* Function call to calculate overtime */ 
 /* Function call to calculate gross pay */

 /* Function call to output results to the screen */

 return (0);


// Function: getInput  
// Purpose: Obtains input from user, the number of hours worked 
// per employee and stores the results in an array that is 
// passed back to the calling program by reference. 
// Parameters: emp_num - Array of employee clock numbers.
// hrs - Array of number of hours worked by an employee
// size - Number of employees to process */
// Returns: Nothing (call by refernce)

void getInput (long emp_num[], float emp_hrs[], int size)

 int count; /* loop counter */

  /* Get Hours for each employee */
 for (count = 0; count < size; ++count)
 printf("\nEnter hours worked by emp # %06li: ", emp_num[count]);
 scanf ("%f", &emp_hrs[count]);


/* Add other functions here as needed */
/* ... remember your comment block headers for each function */


Tutor Answer

(Top Tutor) Studypool Tutor
School: Duke University

Studypool has helped 1,244,100 students

Review from student
Studypool Student
" Totally impressed with results!! :-) "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1829 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors