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