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