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