Write a C program

Write a C program

Write a C program that will calculate the gross pay of a set of employees.

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.

Continue to incorporate functions into your program design.

Use 1.5 as the overtime pay factor.

This week, adding a Total and Average row is no longer optional, its required for this assignment:

a) Add a Total row at the end to sum up the wage, hours, ot, and gross columns
b) Add an Average row to print out the average of the wage, hours, ot, and gross columns

    ---------------------------------------------------------_x000D_
    Name            Clock#   Wage   Hours     OT     Gross_x000D_
    ---------------------------------------------------------_x000D_
    Connie Cobol    098401   10.60   51.0    11.0    598.90_x000D_
    Mary Apl        526488    9.75   42.5     2.5    426.56_x000D_
    Frank Fortran   765349   10.50   37.0     0.0    388.50_x000D_
    Jeff Ada        034645   12.25   45.0     5.0    581.88_x000D_
    Anton Pascal    127615   10.00   40.0     0.0    400.00_x000D_
    ---------------------------------------------------------_x000D_
_x000D_
    Total:                   53.10  215.5    18.5   2395.84_x000D_
    Average:                 10.62   43.1     3.7    479.19_x000D_

You should implement this program using a structure similar to the suggested one below to store the information for each employee. Feel free to tweak it if you wish. For example, its OK to have a first and last name member instead of just a name member, and if you want to use different types, that is OK as well.

    struct employee_x000D_
    {_x000D_
      char  name [20];_x000D_
      long  id_number;_x000D_
      float wage;_x000D_
      float hours;_x000D_
      float overtime;_x000D_
      float gross;_x000D_
    }; 

Use the following information to initialize your data.

    Connie Cobol     98401   10.60   _x000D_
    Mary Apl        526488    9.75_x000D_
    Frank Fortran   765349   10.50_x000D_
    Jeff Ada         34645   12.25_x000D_
    Anton Pascal    127615   10.00_x000D_

In your print function, just add local variables for total wage, total hours, total overtime, and total gross … and keep a running total as you print each employee … at the end of the loop after you have printed all employees, you will have all three totals calculated. Then you can print the totals, calculate the average (now that you know the four totals and number of employees you processed), and print the average after the loop … I sketched out a design below:

Initialize the three local variables for holding the totals to 0

for (i=0; i < size; ++i) /* any loop is fine */

{


/* print each employee … just like we did in the last assignment, add the name member now as well and keep a running total of four local variables */

total_wage += emp[i].wage;

total_hours += emp[i].hours;

total_ot += emp[i].ot;

total_gross += emp[i].gross;

}

/* Print the final values in the four local variables holding the totals */

/* Use the four local variables with the totals to calculate and print the average of hours, overtime, and gross */

I need some comments to the code … in functions.Also, each function needs a function comment header.Comment each local variable declaration

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper