Chat with us, powered by LiveChat Structures | acewriters
+1(978)310-4246 credencewriters@gmail.com
  

/********************************************************************* ** ** HOMEWORK: #5 Structures ** ** Name: [Enter your Name] ** ** Class: C Programming ** ** Date: [enter the date] ** ** Description: This program prompts the user for the number of hours ** worked for each employee. It then calculates gross pay ** including overtime and displays the results in table. Functions ** and structures are used. ** /**********************************************************************/ /*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 n", 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 */

error: Content is protected !!