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