fork download
  1. //********************************************************
  2. //
  3. // Assignment 7 - Structures and Strings
  4. //
  5. // Name: <Alberto DeJesus>
  6. //
  7. // Class: C Programming, <Summer 2026>
  8. //
  9. // Date: <July 12, 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 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.  
  329. printf("\nTotals: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  330. employeeTotals.total_wageRate,
  331. employeeTotals.total_hours,
  332. employeeTotals.total_overtimeHrs, /* total for employee hours and earnings*/
  333. employeeTotals.total_grossPay,
  334. employeeTotals.total_stateTax,
  335. employeeTotals.total_fedTax,
  336. employeeTotals.total_netPay);
  337.  
  338. // make sure you don't divide by zero or a negative number
  339. if (theSize > 0)
  340. {
  341. // print the averages for all the floating point fields
  342.  
  343. printf("\nAverages: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  344. employeeTotals.total_wageRate/theSize,
  345. employeeTotals.total_wageRate/theSize,
  346. employeeTotals.total_hours/theSize,
  347. employeeTotals.total_overtimeHrs/theSize, /* total average information of employee earnings and hours*/
  348. employeeTotals.total_grossPay/theSize,
  349. employeeTotals.total_stateTax/theSize,
  350. employeeTotals.total_fedTax/theSize,
  351. employeeTotals.total_netPay/theSize);
  352. } // if
  353.  
  354. // print the min and max values
  355.  
  356. printf("\nMinimum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  357. employeeMinMax.min_wageRate,
  358. employeeMinMax.min_hours,
  359. employeeMinMax.min_overtimeHrs,
  360. employeeMinMax.min_grossPay,
  361. employeeMinMax.min_stateTax, /*minimum employee hours and pay given total*/
  362. employeeMinMax.min_fedTax,
  363. employeeMinMax.min_netPay);
  364.  
  365.  
  366. printf("\nMaximum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  367. employeeMinMax.max_wageRate,
  368. employeeMinMax.max_hours,
  369. employeeMinMax.max_overtimeHrs,
  370. employeeMinMax.max_grossPay, /*maximum employee hours and pay total*/
  371. employeeMinMax.max_stateTax,
  372. employeeMinMax.max_fedTax,
  373. employeeMinMax.max_netPay);
  374. } // printEmpStatistics
  375.  
  376. //*************************************************************
  377. // Function: calcOvertimeHrs
  378. //
  379. // Purpose: Calculates the overtime hours worked by an employee
  380. // in a given week for each employee.
  381. //
  382. // Parameters:
  383. //
  384. // employeeData - array of employees (i.e., struct employee)
  385. // theSize - the array size (i.e., number of employees)
  386. //
  387. // Returns: void
  388. //
  389. //**************************************************************
  390.  
  391. void calcOvertimeHrs (struct employee employeeData[], int theSize)
  392. {
  393.  
  394. int i; // array and loop index
  395.  
  396. // calculate overtime hours for each employee
  397. for (i = 0; i < theSize; ++i)
  398. {
  399. // Any overtime ?
  400. if (employeeData[i].hours >= STD_HOURS)
  401. {
  402. employeeData[i].overtimeHrs = employeeData[i].hours - STD_HOURS;
  403. }
  404. else // no overtime
  405. {
  406. employeeData[i].overtimeHrs = 0;
  407. }
  408.  
  409. } // for
  410.  
  411.  
  412. } // calcOvertimeHrs
  413.  
  414. //*************************************************************
  415. // Function: calcGrossPay
  416. //
  417. // Purpose: Calculates the gross pay based on the the normal pay
  418. // and any overtime pay for a given week for each
  419. // employee.
  420. //
  421. // Parameters:
  422. //
  423. // employeeData - array of employees (i.e., struct employee)
  424. // theSize - the array size (i.e., number of employees)
  425. //
  426. // Returns: void
  427. //
  428. //**************************************************************
  429.  
  430. void calcGrossPay (struct employee employeeData[], int theSize)
  431. {
  432. int i; // loop and array index
  433. float theNormalPay; // normal pay without any overtime hours
  434. float theOvertimePay; // overtime pay
  435.  
  436. // calculate grossPay for each employee
  437. for (i=0; i < theSize; ++i)
  438. {
  439. // calculate normal pay and any overtime pay
  440. theNormalPay = employeeData[i].wageRate *
  441. (employeeData[i].hours - employeeData[i].overtimeHrs);
  442. theOvertimePay = employeeData[i].overtimeHrs *
  443. (OT_RATE * employeeData[i].wageRate);
  444.  
  445. // calculate gross pay for employee as normalPay + any overtime pay
  446. employeeData[i].grossPay = theNormalPay + theOvertimePay;
  447. }
  448.  
  449. } // calcGrossPay
  450.  
  451. //*************************************************************
  452. // Function: calcStateTax
  453. //
  454. // Purpose: Calculates the State Tax owed based on gross pay
  455. // for each employee. State tax rate is based on the
  456. // the designated tax state based on where the
  457. // employee is actually performing the work. Each
  458. // state decides their tax rate.
  459. //
  460. // Parameters:
  461. //
  462. // employeeData - array of employees (i.e., struct employee)
  463. // theSize - the array size (i.e., number of employees)
  464. //
  465. // Returns: void
  466. //
  467. //**************************************************************
  468.  
  469. void calcStateTax (struct employee employeeData[], int theSize)
  470. {
  471.  
  472. int i; // loop and array index
  473.  
  474. // calculate state tax based on where employee works
  475. for (i=0; i < theSize; ++i)
  476. {
  477. // Make sure tax state is all uppercase
  478. if (islower(employeeData[i].taxState[0]))
  479. employeeData[i].taxState[0] = toupper(employeeData[i].taxState[0]);
  480. if (islower(employeeData[i].taxState[1]))
  481. employeeData[i].taxState[1] = toupper(employeeData[i].taxState[1]);
  482.  
  483. // calculate state tax based on where employee resides
  484. if (strcmp(employeeData[i].taxState, "MA") == 0)
  485. employeeData[i].stateTax = employeeData[i].grossPay * MA_TAX_RATE;
  486. else if (strcmp(employeeData[i].taxState, "NH") == 0)
  487. employeeData[i].stateTax = employeeData[i].grossPay * NH_TAX_RATE;
  488.  
  489.  
  490. else if (strcmp(employeeData[i].taxState, "VT") == 0)
  491. employeeData[i].stateTax = employeeData[i].grossPay * VT_TAX_RATE;
  492.  
  493. else if (strcmp(employeeData[i].taxState, "CA") == 0)
  494. employeeData[i].stateTax = employeeData[i].grossPay * CA_TAX_RATE; /* Gross pay multiplied employee state tax rate*/
  495. else
  496. // any other state is the default rate
  497. employeeData[i].stateTax = employeeData[i].grossPay * DEFAULT_TAX_RATE;
  498. } // for
  499.  
  500. } // calcStateTax
  501.  
  502. //*************************************************************
  503. // Function: calcFedTax
  504. //
  505. // Purpose: Calculates the Federal Tax owed based on the gross
  506. // pay for each employee
  507. //
  508. // Parameters:
  509. //
  510. // employeeData - array of employees (i.e., struct employee)
  511. // theSize - the array size (i.e., number of employees)
  512. //
  513. // Returns: void
  514. //
  515. //**************************************************************
  516.  
  517. void calcFedTax (struct employee employeeData[], int theSize)
  518. {
  519.  
  520. int i; // loop and array index
  521.  
  522. // calculate the federal tax for each employee
  523. for (i=0; i < theSize; ++i)
  524. {
  525.  
  526. employeeData[i].fedTax = employeeData[i].grossPay * FED_TAX_RATE; /*employee gross pay multiplied federal tax rate*/
  527.  
  528. // Fed Tax is the same for all regardless of state
  529. employeeData[i].fedTax = 0;
  530.  
  531. } // for
  532.  
  533. } // calcFedTax
  534.  
  535. //*************************************************************
  536. // Function: calcNetPay
  537. //
  538. // Purpose: Calculates the net pay as the gross pay minus any
  539. // state and federal taxes owed for each employee.
  540. // Essentially, their "take home" pay.
  541. //
  542. // Parameters:
  543. //
  544. // employeeData - array of employees (i.e., struct employee)
  545. // theSize - the array size (i.e., number of employees)
  546. //
  547. // Returns: void
  548. //
  549. //**************************************************************
  550.  
  551. void calcNetPay (struct employee employeeData[], int theSize)
  552. {
  553. int i; // loop and array index
  554. float theTotalTaxes; // the total state and federal tax
  555.  
  556. // calculate the take home pay for each employee
  557. for (i=0; i < theSize; ++i)
  558. {
  559. // calculate the total state and federal taxes
  560. theTotalTaxes = employeeData[i].stateTax + employeeData[i].fedTax;
  561.  
  562.  
  563.  
  564. // calculate the net pay
  565. employeeData[i].netPay = employeeData[i].grossPay - theTotalTaxes; /* gross pay subtracted total taxes for netpay*/
  566.  
  567. } // for
  568.  
  569. } // calcNetPay
  570.  
  571. //*************************************************************
  572. // Function: calcEmployeeTotals
  573. //
  574. // Purpose: Performs a running total (sum) of each employee
  575. // floating point member in the array of structures
  576. //
  577. // Parameters:
  578. //
  579. // employeeData - array of employees (i.e., struct employee)
  580. // employeeTotals - structure containing a running totals
  581. // of all fields above
  582. // theSize - the array size (i.e., number of employees)
  583. //
  584. // Returns: employeeTotals - updated totals in the updated
  585. // employeeTotals structure
  586. //
  587. //**************************************************************
  588.  
  589. struct totals calcEmployeeTotals (struct employee employeeData[],
  590. struct totals employeeTotals,
  591. int theSize)
  592. {
  593.  
  594. int i; // loop and array index
  595.  
  596. // total up each floating point item for all employees
  597. for (i = 0; i < theSize; ++i)
  598. {
  599. // add current employee data to our running totals
  600. employeeTotals.total_wageRate += employeeData[i].wageRate;
  601. employeeTotals.total_hours += employeeData[i].hours;
  602. employeeTotals.total_overtimeHrs += employeeData[i].overtimeHrs;
  603. employeeTotals.total_grossPay += employeeData[i].grossPay;
  604. employeeTotals.total_stateTax += employeeData[i].stateTax;
  605. employeeTotals.total_fedTax += employeeData[i].fedTax;
  606. employeeTotals.total_netPay += employeeData[i].netPay;
  607.  
  608. } // for
  609.  
  610. return (employeeTotals);
  611.  
  612. } // calcEmployeeTotals
  613.  
  614. //*************************************************************
  615. // Function: calcEmployeeMinMax
  616. //
  617. // Purpose: Accepts various floating point values from an
  618. // employee and adds to a running update of min
  619. // and max values
  620. //
  621. // Parameters:
  622. //
  623. // employeeData - array of employees (i.e., struct employee)
  624. // employeeTotals - structure containing a running totals
  625. // of all fields above
  626. // theSize - the array size (i.e., number of employees)
  627. //
  628. // Returns: employeeMinMax - updated employeeMinMax structure
  629. //
  630. //**************************************************************
  631.  
  632. struct min_max calcEmployeeMinMax (struct employee employeeData[],
  633. struct min_max employeeMinMax,
  634. int theSize)
  635. {
  636.  
  637. int i; // array and loop index
  638.  
  639. // if this is the first set of data items, set
  640. // them to the min and max
  641. employeeMinMax.min_wageRate = employeeData[0].wageRate;
  642. employeeMinMax.min_hours = employeeData[0].hours;
  643. employeeMinMax.min_overtimeHrs = employeeData[0].overtimeHrs;
  644. employeeMinMax.min_grossPay = employeeData[0].grossPay;
  645. employeeMinMax.min_stateTax = employeeData[0].stateTax;
  646. employeeMinMax.min_fedTax = employeeData[0].fedTax;
  647. employeeMinMax.min_netPay = employeeData[0].netPay;
  648.  
  649. // set the max to the first element members
  650. employeeMinMax.max_wageRate = employeeData[0].wageRate;
  651. employeeMinMax.max_hours = employeeData[0].hours;
  652. employeeMinMax.max_overtimeHrs = employeeData[0].overtimeHrs;
  653. employeeMinMax.max_grossPay = employeeData[0].grossPay;
  654. employeeMinMax.max_stateTax = employeeData[0].stateTax;
  655. employeeMinMax.max_fedTax = employeeData[0].fedTax;
  656. employeeMinMax.max_netPay = employeeData[0].netPay;
  657.  
  658. // compare the rest of the items to each other for min and max
  659. for (i = 1; i < theSize; ++i)
  660. {
  661.  
  662. // check if current Wage Rate is the new min and/or max
  663. if (employeeData[i].wageRate < employeeMinMax.min_wageRate)
  664. {
  665. employeeMinMax.min_wageRate = employeeData[i].wageRate;
  666. }
  667.  
  668. if (employeeData[i].wageRate > employeeMinMax.max_wageRate)
  669. {
  670. employeeMinMax.max_wageRate = employeeData[i].wageRate;
  671. }
  672.  
  673. /*check if current Hours is the new min and/or max*/
  674. if (employeeData[i].hours < employeeMinMax.min_hours)
  675. {
  676. employeeMinMax.min_hours = employeeData[i].hours;
  677. }
  678.  
  679. if (employeeData[i].hours > employeeMinMax.max_hours)
  680. {
  681. employeeMinMax.max_hours = employeeData[i].hours;
  682. }
  683.  
  684.  
  685. /*check if current Overtime Hours is the new min and/or max*/
  686. if (employeeData[i].overtimeHrs < employeeMinMax.min_overtimeHrs)
  687. {
  688. employeeMinMax.min_overtimeHrs = employeeData[i].overtimeHrs;
  689. }
  690.  
  691. if (employeeData[i].overtimeHrs > employeeMinMax.max_overtimeHrs)
  692. {
  693. employeeMinMax.max_overtimeHrs = employeeData[i].overtimeHrs;
  694. }
  695.  
  696.  
  697. /*check if current Gross Pay is the new min and/or max*/
  698. if (employeeData[i].grossPay < employeeMinMax.min_grossPay)
  699. {
  700. employeeMinMax.min_grossPay = employeeData[i].grossPay;
  701. }
  702.  
  703. if (employeeData[i].grossPay > employeeMinMax.max_grossPay)
  704. {
  705. employeeMinMax.max_grossPay = employeeData[i].grossPay;
  706. }
  707. /*wage comparisons for five employees*/
  708.  
  709. /*check if current State Tax is the new min and/or max*/
  710. if (employeeData[i].stateTax < employeeMinMax.min_stateTax)
  711. {
  712. employeeMinMax.min_stateTax = employeeData[i].stateTax;
  713. }
  714.  
  715. if (employeeData[i].stateTax > employeeMinMax.max_stateTax)
  716. {
  717. employeeMinMax.max_stateTax = employeeData[i].stateTax;
  718. }
  719.  
  720.  
  721. /*check if current Federal Tax is the new min and/or max*/
  722. if (employeeData[i].fedTax < employeeMinMax.min_fedTax)
  723. {
  724. employeeMinMax.min_fedTax = employeeData[i].fedTax;
  725. }
  726.  
  727. if (employeeData[i].fedTax > employeeMinMax.max_fedTax)
  728. {
  729. employeeMinMax.max_fedTax = employeeData[i].fedTax;
  730. }
  731.  
  732.  
  733. /*check if current Net Pay is the new min and/or max*/
  734. if (employeeData[i].netPay < employeeMinMax.min_netPay)
  735. {
  736. employeeMinMax.min_netPay = employeeData[i].netPay;
  737. }
  738.  
  739. if (employeeData[i].netPay > employeeMinMax.max_netPay)
  740. {
  741. employeeMinMax.max_netPay = employeeData[i].netPay;
  742. }
  743.  
  744.  
  745. } // else if
  746.  
  747.  
  748. return (employeeMinMax);
  749.  
  750. } // calcEmployeeMinMax
Success #stdin #stdout 0s 5332KB
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    0.00   568.96
Mary Apl             NH  526488  9.75  42.5   2.5  426.56   0.00    0.00   426.56
Frank Fortran        VT  765349 10.50  37.0   0.0  388.50  23.31    0.00   365.19
Jeff Ada             NY  034645 12.25  45.0   5.0  581.88  46.55    0.00   535.33
Anton Pascal         CA  127615  8.35  40.0   0.0  334.00  23.38    0.00   310.62
---------------------------------------------------------------------------------
Totals:                         51.45 215.5  18.5 2329.84 123.18    0.00  2206.65
Averages:                       10.29  10.3  43.1    3.70 465.97   24.64     0.00
Minimum:                         8.35  37.0   0.0  334.00   0.00    0.00   310.62
Maximum:                        12.25  51.0  11.0  598.90  46.55    0.00   568.96