fork download
  1.  
  2. // Assignment 7 - Structures and Strings
  3. //
  4.  
  5. //
  6. // Description: Program which determines overtime and
  7. // gross pay for a set of employees with outputs sent
  8. // to standard output (the screen).
  9. //
  10. // This assignment also adds the employee name, their tax state,
  11. // and calculates the state tax, federal tax, and net pay. It
  12. // also calculates totals, averages, minimum, and maximum values.
  13. //
  14. // Call by Reference design
  15. //
  16. //********************************************************
  17.  
  18. // necessary header files
  19. #include <stdio.h>
  20. #include <string.h>
  21. #include <ctype.h>
  22.  
  23. // define constants
  24. #define SIZE 5
  25. #define STD_HOURS 40.0
  26. #define OT_RATE 1.5
  27. #define MA_TAX_RATE 0.05
  28. #define NH_TAX_RATE 0.0
  29. #define VT_TAX_RATE 0.06
  30. #define CA_TAX_RATE 0.07
  31. #define DEFAULT_TAX_RATE 0.08
  32. #define NAME_SIZE 20
  33. #define TAX_STATE_SIZE 3
  34. #define FED_TAX_RATE 0.25
  35. #define FIRST_NAME_SIZE 10
  36. #define LAST_NAME_SIZE 10
  37.  
  38. // Define a structure type to store an employee name
  39. // ... note how one could easily extend this to other parts
  40. // parts of a name: Middle, Nickname, Prefix, Suffix, etc.
  41. struct name
  42. {
  43. char firstName[FIRST_NAME_SIZE];
  44. char lastName [LAST_NAME_SIZE];
  45. };
  46.  
  47. // Define a structure type to pass employee data between functions
  48. // Note that the structure type is global, but you don't want a variable
  49. // of that type to be global. Best to declare a variable of that type
  50. // in a function like main or another function and pass as needed.
  51. struct employee
  52. {
  53. struct name empName;
  54. char taxState [TAX_STATE_SIZE];
  55. long int clockNumber;
  56. float wageRate;
  57. float hours;
  58. float overtimeHrs;
  59. float grossPay;
  60. float stateTax;
  61. float fedTax;
  62. float netPay;
  63. };
  64.  
  65. // this structure type defines the totals of all floating point items
  66. // so they can be totaled and used also to calculate averages
  67. struct totals
  68. {
  69. float total_wageRate;
  70. float total_hours;
  71. float total_overtimeHrs;
  72. float total_grossPay;
  73. float total_stateTax;
  74. float total_fedTax;
  75. float total_netPay;
  76. };
  77.  
  78. // this structure type defines the min and max values of all floating
  79. // point items so they can be display in our final report
  80. struct min_max
  81. {
  82. float min_wageRate;
  83. float min_hours;
  84. float min_overtimeHrs;
  85. float min_grossPay;
  86. float min_stateTax;
  87. float min_fedTax;
  88. float min_netPay;
  89. float max_wageRate;
  90. float max_hours;
  91. float max_overtimeHrs;
  92. float max_grossPay;
  93. float max_stateTax;
  94. float max_fedTax;
  95. float max_netPay;
  96. };
  97.  
  98. // define prototypes here for each function except main
  99. void getHours (struct employee employeeData[], int theSize);
  100. void calcOvertimeHrs (struct employee employeeData[], int theSize);
  101. void calcGrossPay (struct employee employeeData[], int theSize);
  102. void printHeader (void);
  103. void printEmp (struct employee employeeData[], int theSize);
  104. void calcStateTax (struct employee employeeData[], int theSize);
  105. void calcFedTax (struct employee employeeData[], int theSize);
  106. void calcNetPay (struct employee employeeData[], int theSize);
  107. struct totals calcEmployeeTotals (struct employee employeeData[],
  108. struct totals employeeTotals,
  109. int theSize);
  110.  
  111. struct min_max calcEmployeeMinMax (struct employee employeeData[],
  112. struct min_max employeeMinMax,
  113. int theSize);
  114.  
  115. void printEmpStatistics (struct totals employeeTotals,
  116. struct min_max employeeMinMax,
  117. int theSize);
  118.  
  119. // Add your other function prototypes if needed here
  120.  
  121. int main ()
  122. {
  123.  
  124. // Set up a local variable to store the employee information
  125. // Initialize the name, tax state, clock number, and wage rate
  126. struct employee employeeData[SIZE] = {
  127. { {"Connie", "Cobol"}, "MA", 98401, 10.60},
  128. { {"Mary", "Apl"}, "NH", 526488, 9.75 },
  129. { {"Frank", "Fortran"}, "VT", 765349, 10.50 },
  130. { {"Jeff", "Ada"}, "NY", 34645, 12.25 },
  131. { {"Anton", "Pascal"},"CA",127615, 8.35 }
  132. };
  133.  
  134. // set up structure to store totals and initialize all to zero
  135. struct totals employeeTotals = {0,0,0,0,0,0,0};
  136.  
  137. // set up structure to store min and max values and initialize all to zero
  138. struct min_max employeeMinMax = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  139.  
  140. // Call functions as needed to read and calculate information
  141.  
  142. // Prompt for the number of hours worked by the employee
  143. getHours (employeeData, SIZE);
  144.  
  145. // Calculate the overtime hours
  146. calcOvertimeHrs (employeeData, SIZE);
  147.  
  148. // Calculate the weekly gross pay
  149. calcGrossPay (employeeData, SIZE);
  150.  
  151. // Calculate the state tax
  152. calcStateTax (employeeData, SIZE);
  153.  
  154. // Calculate the federal tax
  155. calcFedTax (employeeData, SIZE);
  156.  
  157. // Calculate the net pay after taxes
  158. calcNetPay (employeeData, SIZE);
  159.  
  160. // Keep a running sum of the employee totals
  161. // Note: This remains a Call by Value design
  162. employeeTotals = calcEmployeeTotals (employeeData, employeeTotals, SIZE);
  163.  
  164. // Keep a running update of the employee minimum and maximum values
  165. // Note: This remains a Call by Value design
  166. employeeMinMax = calcEmployeeMinMax (employeeData,
  167. employeeMinMax,
  168. SIZE);
  169. // Print the column headers
  170. printHeader();
  171.  
  172. // print out final information on each employee
  173. printEmp (employeeData, SIZE);
  174.  
  175. // print the totals and averages for all float items
  176. printEmpStatistics (employeeTotals, employeeMinMax, SIZE);
  177.  
  178. return (0); // success
  179.  
  180. } // main
  181.  
  182. //**************************************************************
  183. // Function: getHours
  184. //
  185. // Purpose: Obtains input from user, the number of hours worked
  186. // per employee and updates it in the array of structures
  187. // for each employee.
  188. //
  189. // Parameters:
  190. //
  191. // employeeData - array of employees (i.e., struct employee)
  192. // theSize - the array size (i.e., number of employees)
  193. //
  194. // Returns: void
  195. //
  196. //**************************************************************
  197.  
  198. void getHours (struct employee employeeData[], int theSize)
  199. {
  200.  
  201. int i; // array and loop index
  202.  
  203. // read in hours for each employee
  204. for (i = 0; i < theSize; ++i)
  205. {
  206. // Read in hours for employee
  207. printf("\nEnter hours worked by emp # %06li: ", employeeData[i].clockNumber);
  208. (void) scanf ("%f", &employeeData[i].hours);
  209. }
  210.  
  211. } // getHours
  212.  
  213. //**************************************************************
  214. // Function: printHeader
  215. //
  216. // Purpose: Prints the initial table header information.
  217. //
  218. // Parameters: none
  219. //
  220. // Returns: void
  221. //
  222. //**************************************************************
  223.  
  224. void printHeader (void)
  225. {
  226.  
  227. printf ("\n\n*** Pay Calculator ***\n");
  228.  
  229. // print the table header
  230. printf("\n--------------------------------------------------------------");
  231. printf("-------------------");
  232. printf("\nName Tax Clock# Wage Hours OT Gross ");
  233. printf(" State Fed Net");
  234. printf("\n State Pay ");
  235. printf(" Tax Tax Pay");
  236.  
  237. printf("\n--------------------------------------------------------------");
  238. printf("-------------------");
  239.  
  240. } // printHeader
  241.  
  242. //*************************************************************
  243. // Function: printEmp
  244. //
  245. // Purpose: Prints out all the information for each employee
  246. // in a nice and orderly table format.
  247. //
  248. // Parameters:
  249. //
  250. // employeeData - array of struct employee
  251. // theSize - the array size (i.e., number of employees)
  252. //
  253. // Returns: void
  254. //
  255. //**************************************************************
  256.  
  257. void printEmp (struct employee employeeData[], int theSize)
  258. {
  259.  
  260. int i; // array and loop index
  261.  
  262. // used to format the employee name
  263. char name [FIRST_NAME_SIZE + LAST_NAME_SIZE + 1];
  264.  
  265. // read in hours for each employee
  266. for (i = 0; i < theSize; ++i)
  267. {
  268. // While you could just print the first and last name in the printf
  269. // statement that follows, you could also use various C string library
  270. // functions to format the name exactly the way you want it. Breaking
  271. // the name into first and last members additionally gives you some
  272. // flexibility in printing. This also becomes more useful if we decide
  273. // later to store other parts of a person's name. I really did this just
  274. // to show you how to work with some of the common string functions.
  275. strcpy (name, employeeData[i].empName.firstName);
  276. strcat (name, " "); // add a space between first and last names
  277. strcat (name, employeeData[i].empName.lastName);
  278.  
  279. // Print out a single employee
  280. printf("\n%-20.20s %-2.2s %06li %5.2f %4.1f %4.1f %7.2f %6.2f %7.2f %8.2f",
  281. name, employeeData[i].taxState, employeeData[i].clockNumber,
  282. employeeData[i].wageRate, employeeData[i].hours,
  283. employeeData[i].overtimeHrs, employeeData[i].grossPay,
  284. employeeData[i].stateTax, employeeData[i].fedTax,
  285. employeeData[i].netPay);
  286.  
  287. } // for
  288.  
  289. } // printEmp
  290.  
  291. //*************************************************************
  292. // Function: printEmpStatistics
  293. //
  294. // Purpose: Prints out the summary totals and averages of all
  295. // floating point value items for all employees
  296. // that have been processed. It also prints
  297. // out the min and max values.
  298. //
  299. // Parameters:
  300. //
  301. // employeeTotals - a structure containing a running total
  302. // of all employee floating point items
  303. // employeeMinMax - a structure containing all the minimum
  304. // and maximum values of all employee
  305. // floating point items
  306. // theSize - the total number of employees processed, used
  307. // to check for zero or negative divide condition.
  308. //
  309. // Returns: void
  310. //
  311. //**************************************************************
  312.  
  313. void printEmpStatistics (struct totals employeeTotals,
  314. struct min_max employeeMinMax,
  315. int theSize)
  316. {
  317.  
  318. // print a separator line
  319. printf("\n--------------------------------------------------------------");
  320. printf("-------------------");
  321.  
  322. // print the totals for all the floating point fields
  323. // TODO - replace the zeros below with the correct reference to the
  324. // reference to the member total item
  325. printf("\nTotals: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  326. employeeTotals.total_wageRate, employeeTotals.total_hours,
  327. employeeTotals.total_overtimeHrs, employeeTotals.total_grossPay,
  328. employeeTotals.total_stateTax, employeeTotals.total_fedTax,
  329. employeeTotals.total_netPay);
  330.  
  331. // make sure you don't divide by zero or a negative number
  332. if (theSize > 0)
  333. {
  334. // print the averages for all the floating point fields
  335. // TODO - replace the zeros below with the correct reference to the
  336. // the average calculation using with the correct total item
  337. printf("\nAverages: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  338. employeeTotals.total_wageRate / theSize,
  339. employeeTotals.total_hours / theSize,
  340. employeeTotals.total_overtimeHrs / theSize,
  341. employeeTotals.total_grossPay / theSize,
  342. employeeTotals.total_stateTax / theSize,
  343. employeeTotals.total_fedTax / theSize,
  344. employeeTotals.total_netPay / theSize);
  345.  
  346. } // if
  347.  
  348. // print the min and max values
  349. // TODO - replace the zeros below with the correct reference to the
  350. // to the min member field
  351. printf("\nMinimum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  352. employeeMinMax.min_wageRate, employeeMinMax.min_hours,
  353. employeeMinMax.min_overtimeHrs, employeeMinMax.min_grossPay,
  354. employeeMinMax.min_stateTax, employeeMinMax.min_fedTax,
  355. employeeMinMax.min_netPay);
  356.  
  357. // TODO - replace the zeros below with the correct reference to the
  358. // to the max member field
  359. printf("\nMaximum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  360. employeeMinMax.max_wageRate, employeeMinMax.max_hours,
  361. employeeMinMax.max_overtimeHrs, employeeMinMax.max_grossPay,
  362. employeeMinMax.max_stateTax, employeeMinMax.max_fedTax,
  363. employeeMinMax.max_netPay);
  364.  
  365. } // printEmpStatistics
  366.  
  367. //*************************************************************
  368. // Function: calcOvertimeHrs
  369. //
  370. // Purpose: Calculates the overtime hours worked by an employee
  371. // in a given week for each employee.
  372. //
  373. // Parameters:
  374. //
  375. // employeeData - array of employees (i.e., struct employee)
  376. // theSize - the array size (i.e., number of employees)
  377. //
  378. // Returns: void
  379. //
  380. //**************************************************************
  381.  
  382. void calcOvertimeHrs (struct employee employeeData[], int theSize)
  383. {
  384.  
  385. int i; // array and loop index
  386.  
  387. // calculate overtime hours for each employee
  388. for (i = 0; i < theSize; ++i)
  389. {
  390. // Any overtime ?
  391. if (employeeData[i].hours >= STD_HOURS)
  392. {
  393. employeeData[i].overtimeHrs = employeeData[i].hours - STD_HOURS;
  394. }
  395. else // no overtime
  396. {
  397. employeeData[i].overtimeHrs = 0;
  398. }
  399.  
  400. } // for
  401.  
  402.  
  403. } // calcOvertimeHrs
  404.  
  405. //*************************************************************
  406. // Function: calcGrossPay
  407. //
  408. // Purpose: Calculates the gross pay based on the the normal pay
  409. // and any overtime pay for a given week for each
  410. // employee.
  411. //
  412. // Parameters:
  413. //
  414. // employeeData - array of employees (i.e., struct employee)
  415. // theSize - the array size (i.e., number of employees)
  416. //
  417. // Returns: void
  418. //
  419. //**************************************************************
  420.  
  421. void calcGrossPay (struct employee employeeData[], int theSize)
  422. {
  423. int i; // loop and array index
  424. float theNormalPay; // normal pay without any overtime hours
  425. float theOvertimePay; // overtime pay
  426.  
  427. // calculate grossPay for each employee
  428. for (i=0; i < theSize; ++i)
  429. {
  430. // calculate normal pay and any overtime pay
  431. theNormalPay = employeeData[i].wageRate *
  432. (employeeData[i].hours - employeeData[i].overtimeHrs);
  433. theOvertimePay = employeeData[i].overtimeHrs *
  434. (OT_RATE * employeeData[i].wageRate);
  435.  
  436. // calculate gross pay for employee as normalPay + any overtime pay
  437. employeeData[i].grossPay = theNormalPay + theOvertimePay;
  438. }
  439.  
  440. } // calcGrossPay
  441.  
  442. //*************************************************************
  443. // Function: calcStateTax
  444. //
  445. // Purpose: Calculates the State Tax owed based on gross pay
  446. // for each employee. State tax rate is based on the
  447. // the designated tax state based on where the
  448. // employee is actually performing the work. Each
  449. // state decides their tax rate.
  450. //
  451. // Parameters:
  452. //
  453. // employeeData - array of employees (i.e., struct employee)
  454. // theSize - the array size (i.e., number of employees)
  455. //
  456. // Returns: void
  457. //
  458. //**************************************************************
  459.  
  460. void calcStateTax (struct employee employeeData[], int theSize)
  461. {
  462.  
  463. int i; // loop and array index
  464.  
  465. // calculate state tax based on where employee works
  466. for (i=0; i < theSize; ++i)
  467. {
  468. // Make sure tax state is all uppercase
  469. if (islower(employeeData[i].taxState[0]))
  470. employeeData[i].taxState[0] = toupper(employeeData[i].taxState[0]);
  471. if (islower(employeeData[i].taxState[1]))
  472. employeeData[i].taxState[1] = toupper(employeeData[i].taxState[1]);
  473.  
  474. // calculate state tax based on where employee resides
  475. if (strcmp(employeeData[i].taxState, "MA") == 0)
  476. employeeData[i].stateTax = employeeData[i].grossPay * MA_TAX_RATE;
  477. else if (strcmp(employeeData[i].taxState, "NH") == 0)
  478. employeeData[i].stateTax = employeeData[i].grossPay * NH_TAX_RATE;
  479.  
  480. // TODO: Fix the state tax calculations for VT and CA ... right now
  481. // both are set to zero
  482. else if (strcmp(employeeData[i].taxState, "VT") == 0)
  483. employeeData[i].stateTax = employeeData[i].grossPay * VT_TAX_RATE;
  484. else if (strcmp(employeeData[i].taxState, "CA") == 0)
  485. employeeData[i].stateTax = employeeData[i].grossPay * CA_TAX_RATE;
  486. else
  487. // any other state is the default rate
  488. employeeData[i].stateTax = employeeData[i].grossPay * DEFAULT_TAX_RATE;
  489. } // for
  490.  
  491. } // calcStateTax
  492.  
  493. //*************************************************************
  494. // Function: calcFedTax
  495. //
  496. // Purpose: Calculates the Federal Tax owed based on the gross
  497. // pay for each employee
  498. //
  499. // Parameters:
  500. //
  501. // employeeData - array of employees (i.e., struct employee)
  502. // theSize - the array size (i.e., number of employees)
  503. //
  504. // Returns: void
  505. //
  506. //**************************************************************
  507.  
  508. void calcFedTax (struct employee employeeData[], int theSize)
  509. {
  510.  
  511. int i; // loop and array index
  512.  
  513. // calculate the federal tax for each employee
  514. for (i=0; i < theSize; ++i)
  515. {
  516.  
  517. // TODO: Fix the fedTax calculation to be the gross pay
  518. // multiplied by the Federal Tax Rate (use constant
  519. // provided.)
  520.  
  521. // Fed Tax is the same for all regardless of state
  522. employeeData[i].fedTax =
  523. employeeData[i].grossPay * FED_TAX_RATE;
  524.  
  525. } // for
  526.  
  527. } // calcFedTax
  528.  
  529. //*************************************************************
  530. // Function: calcNetPay
  531. //
  532. // Purpose: Calculates the net pay as the gross pay minus any
  533. // state and federal taxes owed for each employee.
  534. // Essentially, their "take home" pay.
  535. //
  536. // Parameters:
  537. //
  538. // employeeData - array of employees (i.e., struct employee)
  539. // theSize - the array size (i.e., number of employees)
  540. //
  541. // Returns: void
  542. //
  543. //**************************************************************
  544.  
  545. void calcNetPay (struct employee employeeData[], int theSize)
  546. {
  547. int i; // loop and array index
  548. float theTotalTaxes; // the total state and federal tax
  549.  
  550. // calculate the take home pay for each employee
  551. for (i=0; i < theSize; ++i)
  552. {
  553. // calculate the total state and federal taxes
  554. theTotalTaxes = employeeData[i].stateTax + employeeData[i].fedTax;
  555.  
  556. // TODO: Fix the netPay calculation to be the gross pay minus the
  557. // the total taxes paid
  558.  
  559. // calculate the net pay
  560. employeeData[i].netPay =
  561. employeeData[i].grossPay - theTotalTaxes;
  562. } // for
  563.  
  564. } // calcNetPay
  565.  
  566. //*************************************************************
  567. // Function: calcEmployeeTotals
  568. //
  569. // Purpose: Performs a running total (sum) of each employee
  570. // floating point member in the array of structures
  571. //
  572. // Parameters:
  573. //
  574. // employeeData - array of employees (i.e., struct employee)
  575. // employeeTotals - structure containing a running totals
  576. // of all fields above
  577. // theSize - the array size (i.e., number of employees)
  578. //
  579. // Returns: employeeTotals - updated totals in the updated
  580. // employeeTotals structure
  581. //
  582. //**************************************************************
  583.  
  584. struct totals calcEmployeeTotals (struct employee employeeData[],
  585. struct totals employeeTotals,
  586. int theSize)
  587. {
  588.  
  589. int i; // loop and array index
  590.  
  591. // total up each floating point item for all employees
  592. for (i = 0; i < theSize; ++i)
  593. {
  594. // add current employee data to our running totals
  595. employeeTotals.total_wageRate += employeeData[i].wageRate;
  596. employeeTotals.total_hours += employeeData[i].hours;
  597. employeeTotals.total_overtimeHrs += employeeData[i].overtimeHrs;
  598. employeeTotals.total_grossPay += employeeData[i].grossPay;
  599. employeeTotals.total_stateTax += employeeData[i].stateTax;
  600. employeeTotals.total_fedTax += employeeData[i].fedTax;
  601. employeeTotals.total_netPay += employeeData[i].netPay;
  602.  
  603. } // for
  604.  
  605. return (employeeTotals);
  606.  
  607. } // calcEmployeeTotals
  608.  
  609. //*************************************************************
  610. // Function: calcEmployeeMinMax
  611. //
  612. // Purpose: Accepts various floating point values from an
  613. // employee and adds to a running update of min
  614. // and max values
  615. //
  616. // Parameters:
  617. //
  618. // employeeData - array of employees (i.e., struct employee)
  619. // employeeTotals - structure containing a running totals
  620. // of all fields above
  621. // theSize - the array size (i.e., number of employees)
  622. //
  623. // Returns: employeeMinMax - updated employeeMinMax structure
  624. //
  625. //**************************************************************
  626.  
  627. struct min_max calcEmployeeMinMax (struct employee employeeData[],
  628. struct min_max employeeMinMax,
  629. int theSize)
  630. {
  631.  
  632. int i; // array and loop index
  633.  
  634. // if this is the first set of data items, set
  635. // them to the min and max
  636. employeeMinMax.min_wageRate = employeeData[0].wageRate;
  637. employeeMinMax.min_hours = employeeData[0].hours;
  638. employeeMinMax.min_overtimeHrs = employeeData[0].overtimeHrs;
  639. employeeMinMax.min_grossPay = employeeData[0].grossPay;
  640. employeeMinMax.min_stateTax = employeeData[0].stateTax;
  641. employeeMinMax.min_fedTax = employeeData[0].fedTax;
  642. employeeMinMax.min_netPay = employeeData[0].netPay;
  643.  
  644. // set the max to the first element members
  645. employeeMinMax.max_wageRate = employeeData[0].wageRate;
  646. employeeMinMax.max_hours = employeeData[0].hours;
  647. employeeMinMax.max_overtimeHrs = employeeData[0].overtimeHrs;
  648. employeeMinMax.max_grossPay = employeeData[0].grossPay;
  649. employeeMinMax.max_stateTax = employeeData[0].stateTax;
  650. employeeMinMax.max_fedTax = employeeData[0].fedTax;
  651. employeeMinMax.max_netPay = employeeData[0].netPay;
  652.  
  653. // compare the rest of the items to each other for min and max
  654. for (i = 1; i < theSize; ++i)
  655. {
  656.  
  657. // check if current Wage Rate is the new min and/or max
  658. if (employeeData[i].wageRate < employeeMinMax.min_wageRate)
  659. {
  660. employeeMinMax.min_wageRate = employeeData[i].wageRate;
  661. }
  662.  
  663. if (employeeData[i].wageRate > employeeMinMax.max_wageRate)
  664. {
  665. employeeMinMax.max_wageRate = employeeData[i].wageRate;
  666. }
  667.  
  668. // TODO: do the same checking for all the other min and max items
  669. // ... just repeat the two "if statements" with the right
  670. // reference between the specific min and max fields and
  671. // employeeData array of structures item.
  672. {
  673. if (employeeData[i].hours < employeeMinMax.min_hours)
  674. employeeMinMax.min_hours = employeeData[i].hours;
  675. if (employeeData[i].hours > employeeMinMax.max_hours)
  676. employeeMinMax.max_hours = employeeData[i].hours;
  677.  
  678. if (employeeData[i].overtimeHrs < employeeMinMax.min_overtimeHrs)
  679. employeeMinMax.min_overtimeHrs = employeeData[i].overtimeHrs;
  680. if (employeeData[i].overtimeHrs > employeeMinMax.max_overtimeHrs)
  681. employeeMinMax.max_overtimeHrs = employeeData[i].overtimeHrs;
  682.  
  683. if (employeeData[i].grossPay < employeeMinMax.min_grossPay)
  684. employeeMinMax.min_grossPay = employeeData[i].grossPay;
  685. if (employeeData[i].grossPay > employeeMinMax.max_grossPay)
  686. employeeMinMax.max_grossPay = employeeData[i].grossPay;
  687.  
  688. if (employeeData[i].stateTax < employeeMinMax.min_stateTax)
  689. employeeMinMax.min_stateTax = employeeData[i].stateTax;
  690. if (employeeData[i].stateTax > employeeMinMax.max_stateTax)
  691. employeeMinMax.max_stateTax = employeeData[i].stateTax;
  692.  
  693. if (employeeData[i].fedTax < employeeMinMax.min_fedTax)
  694. employeeMinMax.min_fedTax = employeeData[i].fedTax;
  695. if (employeeData[i].fedTax > employeeMinMax.max_fedTax)
  696. employeeMinMax.max_fedTax = employeeData[i].fedTax;
  697.  
  698. if (employeeData[i].netPay < employeeMinMax.min_netPay)
  699. employeeMinMax.min_netPay = employeeData[i].netPay;
  700. if (employeeData[i].netPay > employeeMinMax.max_netPay)
  701. employeeMinMax.max_netPay = employeeData[i].netPay;
  702. }
  703.  
  704. } // else if
  705.  
  706. // return all the updated min and max values to the calling function
  707. return (employeeMinMax);
  708.  
  709. } // calcEmployeeMinMax
Success #stdin #stdout 0.01s 5284KB
stdin
51.0
42.5
37.0
45.0
40.0
stdout
Enter hours worked by emp # 098401: 
Enter hours worked by emp # 526488: 
Enter hours worked by emp # 765349: 
Enter hours worked by emp # 034645: 
Enter hours worked by emp # 127615: 

*** Pay Calculator ***

---------------------------------------------------------------------------------
Name                Tax  Clock# Wage   Hours  OT   Gross   State  Fed      Net
                   State                           Pay     Tax    Tax      Pay
---------------------------------------------------------------------------------
Connie Cobol         MA  098401 10.60  51.0  11.0  598.90  29.95  149.73   419.23
Mary Apl             NH  526488  9.75  42.5   2.5  426.56   0.00  106.64   319.92
Frank Fortran        VT  765349 10.50  37.0   0.0  388.50  23.31   97.12   268.07
Jeff Ada             NY  034645 12.25  45.0   5.0  581.88  46.55  145.47   389.86
Anton Pascal         CA  127615  8.35  40.0   0.0  334.00  23.38   83.50   227.12
---------------------------------------------------------------------------------
Totals:                         51.45 215.5  18.5 2329.84 123.18  582.46  1624.19
Averages:                       10.29  43.1   3.7  465.97  24.64  116.49   324.84
Minimum:                         8.35  37.0   0.0  334.00   0.00   83.50   227.12
Maximum:                        12.25  51.0  11.0  598.90  46.55  149.73   419.23