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