fork download
  1. //********************************************************
  2. //
  3. // Assignment 7 - Structures and Strings
  4. //
  5. // Name: Heather Grothe
  6. //
  7. // Class: C Programming, Spring 2026
  8. //
  9. // Date: March 27, 2026
  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. struct totals
  67. {
  68. float total_wageRate;
  69. float total_hours;
  70. float total_overtimeHrs;
  71. float total_grossPay;
  72. float total_stateTax;
  73. float total_fedTax;
  74. float total_netPay;
  75. };
  76.  
  77. // this structure type defines the min and max values of all floating
  78. // point items so they can be display in our final report
  79. struct min_max
  80. {
  81. float min_wageRate;
  82. float min_hours;
  83. float min_overtimeHrs;
  84. float min_grossPay;
  85. float min_stateTax;
  86. float min_fedTax;
  87. float min_netPay;
  88. float max_wageRate;
  89. float max_hours;
  90. float max_overtimeHrs;
  91. float max_grossPay;
  92. float max_stateTax;
  93. float max_fedTax;
  94. float max_netPay;
  95. };
  96.  
  97. // define prototypes here for each function except main
  98. float getHours (long int clockNumber);
  99. float calcOvertimeHrs (float hours);
  100. float calcGrossPay (float wageRate, float hours, float overtimeHrs);
  101. void printHeader (void);
  102.  
  103. void printEmp (char firstName [], char lastName [], char taxState [],
  104. long int clockNumber, float wageRate,
  105. float hours, float overtimeHrs, float grossPay,
  106. float stateTax, float fedTax, float netPay);
  107.  
  108. float calcStateTax (float grossPay, char taxState[]);
  109. float calcFedTax (float grossPay);
  110. float calcNetPay (float grossPay, float stateTax, float fedTax);
  111.  
  112. struct totals calcEmployeeTotals (float wageRate,
  113. float hours,
  114. float overtimeHrs,
  115. float grossPay,
  116. float stateTax,
  117. float fedTax,
  118. float netPay,
  119. struct totals employeeTotals);
  120.  
  121. struct min_max calcEmployeeMinMax (float wageRate,
  122. float hours,
  123. float overtimeHrs,
  124. float grossPay,
  125. float stateTax,
  126. float fedTax,
  127. float netPay,
  128. struct min_max employeeMinMax,
  129. int arrayIndex);
  130.  
  131. void printEmpStatistics (struct totals employeeTotals,
  132. struct min_max employeeMinMax,
  133. int theSize);
  134.  
  135. int main ()
  136. {
  137.  
  138. int i; // loop and array index
  139.  
  140. // Set up a local variable to store the employee information
  141. // Initialize the name, tax state, clock number, and wage rate
  142. struct employee employeeData[SIZE] = {
  143. { {"Connie", "Cobol"}, "MA", 98401, 10.60},
  144. { {"Mary", "Apl"}, "NH", 526488, 9.75 },
  145. { {"Frank", "Fortran"}, "VT", 765349, 10.50 },
  146. { {"Jeff", "Ada"}, "NY", 34645, 12.25 },
  147. { {"Anton", "Pascal"},"CA",127615, 8.35 }
  148. };
  149.  
  150. // set up structure to store totals and initialize all to zero
  151. struct totals employeeTotals = {0,0,0,0,0,0,0};
  152.  
  153. // set up structure to store min and max values and initialize all to zero
  154. struct min_max employeeMinMax = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  155.  
  156. // Call functions as needed to read and calculate information
  157. for (i = 0; i < SIZE; ++i)
  158. {
  159.  
  160. // Prompt for the number of hours worked by the employee
  161. employeeData[i].hours = getHours (employeeData[i].clockNumber);
  162.  
  163. // Calculate the overtime hours
  164. employeeData[i].overtimeHrs = calcOvertimeHrs (employeeData[i].hours);
  165.  
  166. // Calculate the weekly gross pay
  167. employeeData[i].grossPay = calcGrossPay (employeeData[i].wageRate,
  168. employeeData[i].hours,
  169. employeeData[i].overtimeHrs);
  170.  
  171. // Calculate the state tax
  172. employeeData[i].stateTax = calcStateTax (employeeData[i].grossPay,
  173. employeeData[i].taxState);
  174.  
  175. // Calculate the federal tax
  176. employeeData[i].fedTax = calcFedTax (employeeData[i].grossPay);
  177.  
  178. // Calculate the net pay after taxes
  179. employeeData[i].netPay = calcNetPay (employeeData[i].grossPay,
  180. employeeData[i].stateTax,
  181. employeeData[i].fedTax);
  182.  
  183. // Keep a running sum of the employee totals
  184. employeeTotals = calcEmployeeTotals (employeeData[i].wageRate,
  185. employeeData[i].hours,
  186. employeeData[i].overtimeHrs,
  187. employeeData[i].grossPay,
  188. employeeData[i].stateTax,
  189. employeeData[i].fedTax,
  190. employeeData[i].netPay,
  191. employeeTotals);
  192.  
  193. // Keep a running update of the employee minimum and maximum values
  194. employeeMinMax = calcEmployeeMinMax (employeeData[i].wageRate,
  195. employeeData[i].hours,
  196. employeeData[i].overtimeHrs,
  197. employeeData[i].grossPay,
  198. employeeData[i].stateTax,
  199. employeeData[i].fedTax,
  200. employeeData[i].netPay,
  201. employeeMinMax,
  202. i);
  203.  
  204. } // for
  205.  
  206. // Print the column headers
  207. printHeader();
  208.  
  209. // print out final information on each employee
  210. for (i = 0; i < SIZE; ++i)
  211. {
  212. printEmp (employeeData[i].empName.firstName,
  213. employeeData[i].empName.lastName,
  214. employeeData[i].taxState,
  215. employeeData[i].clockNumber,
  216. employeeData[i].wageRate,
  217. employeeData[i].hours,
  218. employeeData[i].overtimeHrs,
  219. employeeData[i].grossPay,
  220. employeeData[i].stateTax,
  221. employeeData[i].fedTax,
  222. employeeData[i].netPay);
  223. } // for
  224.  
  225. // print the totals and averages for all float items
  226. printEmpStatistics (employeeTotals, employeeMinMax, SIZE);
  227.  
  228. return (0); // success
  229.  
  230. } // main
  231.  
  232. //**************************************************************
  233. // Function: getHours
  234. //
  235. // Purpose: Obtains input from user, the number of hours worked
  236. // per employee and stores the result in a local variable
  237. // that is passed back to the calling function.
  238. //
  239. // Parameters:
  240. //
  241. // clockNumber - The unique employee ID
  242. //
  243. // Returns: theHoursWorked - hours worked in a given week
  244. //
  245. //**************************************************************
  246.  
  247. float getHours (long int clockNumber)
  248. {
  249.  
  250. float theHoursWorked; // hours worked in a given week
  251.  
  252. // Read in hours for employee
  253. printf("\nEnter hours worked by emp # %06li: ", clockNumber);
  254. scanf ("%f", &theHoursWorked);
  255.  
  256. // return hours back to the calling function
  257. return (theHoursWorked);
  258.  
  259. } // getHours
  260.  
  261. //**************************************************************
  262. // Function: printHeader
  263. //
  264. // Purpose: Prints the initial table header information.
  265. //
  266. // Parameters: none
  267. //
  268. // Returns: void
  269. //
  270. //**************************************************************
  271.  
  272. void printHeader (void)
  273. {
  274.  
  275. printf ("\n\n*** Pay Calculator ***\n");
  276.  
  277. // print the table header
  278. printf("\n--------------------------------------------------------------");
  279. printf("-------------------");
  280. printf("\nName Tax Clock# Wage Hours OT Gross ");printf(" State Fed Net");
  281. printf("\n State Pay ");
  282. printf(" Tax Tax Pay");
  283. printf("\n--------------------------------------------------------------");
  284. printf("-------------------");
  285.  
  286. } // printHeader
  287.  
  288. //*************************************************************
  289. // Function: printEmp
  290. //
  291. // Purpose: Prints out all the information for an employee
  292. // in a nice and orderly table format.
  293. //
  294. // Parameters:
  295. //
  296. // firstName - the employee first name
  297. // lastName - the employee last name
  298. // taxState - the state where the employee works
  299. // clockNumber - unique employee ID
  300. // wageRate - hourly wage rate
  301. // hours - Hours worked for the week
  302. // overtimeHrs - overtime hours worked in a week
  303. // grossPay - gross pay for the week
  304. // stateTax - the calculated state tax
  305. // fedTax - the calculated federal tax
  306. // netPay - the calculated take home pay after taxes
  307. //
  308. // Returns: void
  309. //
  310. //**************************************************************
  311.  
  312. void printEmp (char firstName [], char lastName [], char taxState [],
  313. long int clockNumber, float wageRate,
  314. float hours, float overtimeHrs, float grossPay,
  315. float stateTax, float fedTax, float netPay)
  316. {
  317.  
  318. // Used to format the employee name
  319. char name [FIRST_NAME_SIZE + LAST_NAME_SIZE + 1];
  320.  
  321. strcpy (name, firstName);
  322. strcat (name, " ");
  323. strcat (name, lastName);
  324.  
  325. // Print out a single employee
  326. printf("\n%-20.20s %-2.2s %06li %5.2f %4.1f %4.1f %7.2f %6.2f %7.2f %8.2f",
  327. name, taxState, clockNumber, wageRate, hours,
  328. overtimeHrs, grossPay, stateTax, fedTax, netPay);
  329.  
  330. } // printEmp
  331.  
  332. //*************************************************************
  333. // Function: printEmpStatistics
  334. //
  335. // Purpose: Prints out the totals and averages of all
  336. // floating point value items for all employees
  337. // that have been processed.
  338. //
  339. // Parameters:
  340. //
  341. // employeeTotals - a structure containing a running total
  342. // of all employee floating point items
  343. // employeeMinMax - a structure containing all the minimum
  344. // and maximum values of all employee
  345. // floating point items
  346. // theSize - the total number of employees processed, used
  347. // to check for zero or negative divide condition.
  348. //
  349. // Returns: void
  350. //
  351. //**************************************************************
  352.  
  353. void printEmpStatistics (struct totals employeeTotals,
  354. struct min_max employeeMinMax,
  355. int theSize)
  356. {
  357.  
  358. // print a separator line
  359. printf("\n--------------------------------------------------------------");
  360. printf("-------------------");
  361.  
  362. // print the totals for all the floating point fields
  363. printf("\nTotals: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  364. employeeTotals.total_wageRate,
  365. employeeTotals.total_hours,
  366. employeeTotals.total_overtimeHrs,
  367. employeeTotals.total_grossPay,
  368. employeeTotals.total_stateTax,
  369. employeeTotals.total_fedTax,
  370. employeeTotals.total_netPay);
  371.  
  372. // make sure you don't divide by zero or a negative number
  373. if (theSize > 0)
  374. {
  375. // print the averages for all the floating point fields
  376. printf("\nAverages: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  377. employeeTotals.total_wageRate/theSize,
  378. employeeTotals.total_hours/theSize,
  379. employeeTotals.total_overtimeHrs/theSize,
  380. employeeTotals.total_grossPay/theSize,
  381. employeeTotals.total_stateTax/theSize,
  382. employeeTotals.total_fedTax/theSize,
  383. employeeTotals.total_netPay/theSize);
  384. } // if
  385.  
  386. // print the min values
  387. printf("\nMinimum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  388. employeeMinMax.min_wageRate,
  389. employeeMinMax.min_hours,
  390. employeeMinMax.min_overtimeHrs,
  391. employeeMinMax.min_grossPay,
  392. employeeMinMax.min_stateTax,
  393. employeeMinMax.min_fedTax,
  394. employeeMinMax.min_netPay);
  395.  
  396. // print the max values
  397. printf("\nMaximum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  398. employeeMinMax.max_wageRate,
  399. employeeMinMax.max_hours,
  400. employeeMinMax.max_overtimeHrs,
  401. employeeMinMax.max_grossPay,
  402. employeeMinMax.max_stateTax,
  403. employeeMinMax.max_fedTax,
  404. employeeMinMax.max_netPay);
  405.  
  406. } // printEmpStatistics
  407.  
  408. //*************************************************************
  409. // Function: calcOvertimeHrs
  410. //
  411. // Purpose: Calculates the overtime hours worked by an employee
  412. // in a given week.
  413. //
  414. // Parameters:
  415. //
  416. // hours - Hours worked in a given week
  417. //
  418. // Returns: theOvertimeHrs - overtime hours worked by an employee
  419. // in a given week
  420. //
  421. //**************************************************************
  422.  
  423. float calcOvertimeHrs (float hours)
  424. {
  425.  
  426. float theOvertimeHrs; // calculated overtime hours for employee
  427.  
  428. // Any overtime ?
  429. if (hours >= STD_HOURS)
  430. {
  431. theOvertimeHrs = hours - STD_HOURS;
  432. }//if
  433. else
  434. {
  435. theOvertimeHrs = 0;
  436. }//else
  437.  
  438. // return overtime hours back to the calling function
  439. return (theOvertimeHrs);
  440.  
  441. } // calcOvertimeHrs
  442.  
  443. //*************************************************************
  444. // Function: calcGrossPay
  445. //
  446. // Purpose: Calculates the gross pay based on the the normal pay
  447. // and any overtime pay for a given week.
  448. //
  449. // Parameters:
  450. //
  451. // wageRate - the hourly wage rate
  452. // hours - the hours worked in a given week
  453. // overtimeHrs - hours worked above normal hours
  454. //
  455. // Returns: theGrossPay - total weekly gross pay for an employee
  456. //
  457. //**************************************************************
  458.  
  459. float calcGrossPay (float wageRate, float hours, float overtimeHrs)
  460. {
  461.  
  462. float theGrossPay; // gross pay earned in a given week
  463. float theNormalPay; // normal pay without any overtime hours
  464. float theOvertimePay; // overtime pay
  465.  
  466. // calculate normal pay and any overtime pay
  467. theNormalPay = wageRate * (hours - overtimeHrs);
  468. theOvertimePay = overtimeHrs * (OT_RATE * wageRate);
  469.  
  470. // calculate gross pay for employee as normalPay + any overtime pay
  471. theGrossPay = theNormalPay + theOvertimePay;
  472.  
  473. // return the calculated gross pay value back
  474. return (theGrossPay);
  475.  
  476. } // calcGrossPay
  477.  
  478. //*************************************************************
  479. // Function: calcStateTax
  480. //
  481. // Purpose: Calculates the State Tax owed based on gross pay
  482. //
  483. // Parameters:
  484. //
  485. // grossPay - the grossPay for a given week
  486. // taxState - the physical state where the employee works
  487. //
  488. // Returns: theStateTax - calculated state tax owed
  489. //
  490. //**************************************************************
  491.  
  492. float calcStateTax (float grossPay, char taxState[])
  493. {
  494.  
  495. float theStateTax; // calculated state tax
  496.  
  497. theStateTax = grossPay;
  498.  
  499. // Make sure tax state is all uppercase
  500. if (islower(taxState[0]))
  501. {
  502. taxState[0] = toupper(taxState[0]);
  503. }//if
  504.  
  505. if (islower(taxState[1]))
  506. {
  507. taxState[1] = toupper(taxState[1]);
  508. }//if
  509.  
  510. // calculate state tax based on where employee resides
  511. if (strcmp(taxState, "MA") == 0)
  512. {
  513. theStateTax *= MA_TAX_RATE;
  514. }//if
  515. else if (strcmp(taxState, "NH") == 0)
  516. {
  517. theStateTax *= NH_TAX_RATE;
  518. }//else if
  519. else if (strcmp(taxState, "VT") == 0)
  520. {
  521. theStateTax *= VT_TAX_RATE;
  522. }//else if
  523. else if (strcmp(taxState, "CA") == 0)
  524. {
  525. theStateTax *= CA_TAX_RATE;
  526. }//else if
  527. else
  528. {
  529. theStateTax *= DEFAULT_TAX_RATE;
  530. }//else
  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. // employeeMinMax - structure containing min and max values
  661. // arrayIndex - current employee array index
  662. //
  663. // Returns: employeeMinMax - updated employeeMinMax structure
  664. //
  665. //**************************************************************
  666.  
  667. struct min_max calcEmployeeMinMax (float wageRate,
  668. float hours,
  669. float overtimeHrs,
  670. float grossPay,
  671. float stateTax,
  672. float fedTax,
  673. float netPay,
  674. struct min_max employeeMinMax,
  675. int arrayIndex)
  676. {
  677.  
  678. // if this is the first set of data items, set
  679. // them to the min and max
  680. if (arrayIndex == 0)
  681. {
  682. employeeMinMax.min_wageRate = wageRate;
  683. employeeMinMax.min_hours = hours;
  684. employeeMinMax.min_overtimeHrs = overtimeHrs;
  685. employeeMinMax.min_grossPay = grossPay;
  686. employeeMinMax.min_stateTax = stateTax;
  687. employeeMinMax.min_fedTax = fedTax;
  688. employeeMinMax.min_netPay = netPay;
  689.  
  690. employeeMinMax.max_wageRate = wageRate;
  691. employeeMinMax.max_hours = hours;
  692. employeeMinMax.max_overtimeHrs = overtimeHrs;
  693. employeeMinMax.max_grossPay = grossPay;
  694. employeeMinMax.max_stateTax = stateTax;
  695. employeeMinMax.max_fedTax = fedTax;
  696. employeeMinMax.max_netPay = netPay;
  697.  
  698. }// if
  699.  
  700. else if (arrayIndex >=1) // process if other array elements
  701. {
  702. // check if current Wage Rate is the new min and/or max
  703. if (wageRate < employeeMinMax.min_wageRate)
  704. {
  705. employeeMinMax.min_wageRate = wageRate;
  706. }//if
  707.  
  708. if (wageRate > employeeMinMax.max_wageRate)
  709. {
  710. employeeMinMax.max_wageRate = wageRate;
  711. }//if
  712.  
  713. if (hours < employeeMinMax.min_hours)
  714. {
  715. employeeMinMax.min_hours = hours;
  716. }//if
  717.  
  718. if (hours > employeeMinMax.max_hours)
  719. {
  720. employeeMinMax.max_hours = hours;
  721. }//if
  722.  
  723. if (overtimeHrs < employeeMinMax.min_overtimeHrs)
  724. {
  725. employeeMinMax.min_overtimeHrs = overtimeHrs;
  726. }//if
  727.  
  728. if (overtimeHrs > employeeMinMax.max_overtimeHrs)
  729. {
  730. employeeMinMax.max_overtimeHrs = overtimeHrs;
  731. }//if
  732.  
  733. if (grossPay < employeeMinMax.min_grossPay)
  734. {
  735. employeeMinMax.min_grossPay = grossPay;
  736. }//if
  737.  
  738. if (grossPay > employeeMinMax.max_grossPay)
  739. {
  740. employeeMinMax.max_grossPay = grossPay;
  741. }//if
  742.  
  743. if (stateTax < employeeMinMax.min_stateTax)
  744. {
  745. employeeMinMax.min_stateTax = stateTax;
  746. }//if
  747.  
  748. if (stateTax > employeeMinMax.max_stateTax)
  749. {
  750. employeeMinMax.max_stateTax = stateTax;
  751. }//if
  752.  
  753. if (fedTax < employeeMinMax.min_fedTax)
  754. {
  755. employeeMinMax.min_fedTax = fedTax;
  756. }//if
  757.  
  758. if (fedTax > employeeMinMax.max_fedTax)
  759. {
  760. employeeMinMax.max_fedTax = fedTax;
  761. }//if
  762.  
  763. if (netPay < employeeMinMax.min_netPay)
  764. {
  765. employeeMinMax.min_netPay = netPay;
  766. }//if
  767.  
  768. if (netPay > employeeMinMax.max_netPay)
  769. {
  770. employeeMinMax.max_netPay = netPay;
  771. }//if
  772.  
  773. }//else if
  774.  
  775. // return all the updated min and max values to the calling function
  776. return (employeeMinMax);
  777.  
  778. } // calcEmployeeMinMax
Success #stdin #stdout 0.01s 5308KB
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