fork download
  1. //********************************************************
  2. //
  3. // Assignment 10 - Linked Lists, Typedef, and Macros
  4. //
  5. // Name: Emma Carbone
  6. //
  7. // Class: C Programming, Spring 2025
  8. //
  9. // Date: 4/15/2025
  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 have all been replaced with
  20. // pointer references to speed up the processing of this code.
  21. // A linked list has been created and deployed to dynamically
  22. // allocate and process employees as needed.
  23. //
  24. // It will also take advantage of the C Preprocessor features,
  25. // in particular with using macros, and will replace all
  26. // struct type references in the code with a typedef alias
  27. // reference.
  28. //
  29. // Call by Reference design (using pointers)
  30. //
  31. //********************************************************
  32.  
  33. // necessary header files
  34. #include <stdio.h>
  35. #include <string.h>
  36. #include <ctype.h> // for char functions
  37. #include <stdlib.h> // for malloc
  38.  
  39. // define constants
  40. #define STD_HOURS 40.0
  41. #define OT_RATE 1.5
  42. #define MA_TAX_RATE 0.05
  43. #define NH_TAX_RATE 0.0
  44. #define VT_TAX_RATE 0.06
  45. #define CA_TAX_RATE 0.07
  46. #define DEFAULT_STATE_TAX_RATE 0.08
  47. #define NAME_SIZE 20
  48. #define TAX_STATE_SIZE 3
  49. #define FED_TAX_RATE 0.25
  50. #define FIRST_NAME_SIZE 10
  51. #define LAST_NAME_SIZE 10
  52.  
  53. // define macros
  54. #define CALC_OT_HOURS(theHours) ((theHours > STD_HOURS) ? theHours - STD_HOURS : 0)
  55. #define CALC_STATE_TAX(thePay,theStateTaxRate) (thePay * theStateTaxRate)
  56. #define CALC_FED_TAX(thePay,theFedTaxRate) (thePay * theFedTaxRate)
  57. #define CALC_NET_PAY(thePay,theStateTax,theFedTax) (thePay - ((theStateTax) + (theFedTax)))
  58. #define CALC_NORMAL_PAY(theWageRate,theHours,theOvertimeHrs) \
  59.   ((theWageRate) * ((theHours) - (theOvertimeHrs)))
  60. #define CALC_OT_PAY(theWageRate,theOvertimeHrs) ((theOvertimeHrs) * (OT_RATE * (theWageRate)))
  61. #define CALC_MIN(theValue, currentMin) ((theValue) < (currentMin) ? (theValue) : (currentMin))
  62. #define CALC_MAX(theValue, currentMax) ((theValue) > (currentMax) ? (theValue) : (currentMax))
  63.  
  64. // Define a global structure type to store an employee name
  65. // ... note how one could easily extend this to other parts
  66. // parts of a name: Middle, Nickname, Prefix, Suffix, etc.
  67. struct name
  68. {
  69. char firstName[FIRST_NAME_SIZE];
  70. char lastName [LAST_NAME_SIZE];
  71. };
  72.  
  73. // Define a global structure type to pass employee data between functions
  74. // Note that the structure type is global, but you don't want a variable
  75. // of that type to be global. Best to declare a variable of that type
  76. // in a function like main or another function and pass as needed.
  77. // Also note the "next" member has been added as a pointer to structure employee.
  78. // This allows us to point to another data item of this same type,
  79. // allowing us to set up and traverse through all the linked
  80. // list nodes, with each node containing the employee information below.
  81. typedef struct employee
  82. {
  83. struct name empName;
  84. char taxState [TAX_STATE_SIZE];
  85. long int clockNumber;
  86. float wageRate;
  87. float hours;
  88. float overtimeHrs;
  89. float grossPay;
  90. float stateTax;
  91. float fedTax;
  92. float netPay;
  93. struct employee * next;
  94. } EMPLOYEE;
  95.  
  96. // This structure type defines the totals of all floating point items
  97. // so they can be totaled and used also to calculate averages
  98. typedef struct totals
  99. {
  100. float total_wageRate;
  101. float total_hours;
  102. float total_overtimeHrs;
  103. float total_grossPay;
  104. float total_stateTax;
  105. float total_fedTax;
  106. float total_netPay;
  107. } TOTALS;
  108.  
  109. // This structure type defines the min and max values of all floating
  110. // point items so they can be display in our final report
  111. // Also note the use of typedef to create an alias for struct min_max
  112. typedef struct min_max
  113. {
  114. float min_wageRate;
  115. float min_hours;
  116. float min_overtimeHrs;
  117. float min_grossPay;
  118. float min_stateTax;
  119. float min_fedTax;
  120. float min_netPay;
  121. float max_wageRate;
  122. float max_hours;
  123. float max_overtimeHrs;
  124. float max_grossPay;
  125. float max_stateTax;
  126. float max_fedTax;
  127. float max_netPay;
  128. } MIN_MAX;
  129.  
  130. // Function prototypes
  131. EMPLOYEE * getEmpData (void);
  132. int isEmployeeSize (EMPLOYEE * head_ptr);
  133. void calcOvertimeHrs (EMPLOYEE * head_ptr);
  134. void calcGrossPay (EMPLOYEE * head_ptr);
  135. void printHeader (void);
  136. void printEmp (EMPLOYEE * head_ptr);
  137. void calcStateTax (EMPLOYEE * head_ptr);
  138. void calcFedTax (EMPLOYEE * head_ptr);
  139. void calcNetPay (EMPLOYEE * head_ptr);
  140. void calcEmployeeTotals (EMPLOYEE * head_ptr,
  141. TOTALS * emp_totals_ptr);
  142. void calcEmployeeMinMax (EMPLOYEE * head_ptr,
  143. MIN_MAX * emp_minMax_ptr);
  144. void printEmpStatistics (TOTALS * emp_totals_ptr,
  145. MIN_MAX * emp_minMax_ptr,
  146. int theSize);
  147.  
  148. int main ()
  149. {
  150. EMPLOYEE * head_ptr; // always points to first linked list node
  151. int theSize;
  152.  
  153. // set up structure to store totals and initialize all to zero
  154. TOTALS employeeTotals = {0,0,0,0,0,0,0};
  155. TOTALS * emp_totals_ptr = &employeeTotals;
  156.  
  157. // set up structure to store min and max values and initialize all to zero
  158. MIN_MAX employeeMinMax = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  159. MIN_MAX * emp_minMax_ptr = &employeeMinMax;
  160.  
  161. // read input and build linked list
  162. head_ptr = getEmpData ();
  163. theSize = isEmployeeSize (head_ptr);
  164.  
  165. if (theSize <= 0)
  166. {
  167. // print a user friendly message
  168. printf("\n\n**** There was no employee input to process ***\n");
  169. }
  170. else
  171. {
  172. // process all calculations
  173. calcOvertimeHrs (head_ptr);
  174. calcGrossPay (head_ptr);
  175. calcStateTax (head_ptr);
  176. calcFedTax (head_ptr);
  177. calcNetPay (head_ptr);
  178. calcEmployeeTotals (head_ptr, emp_totals_ptr);
  179. calcEmployeeMinMax (head_ptr, emp_minMax_ptr);
  180.  
  181. // output results
  182. printHeader();
  183. printEmp (head_ptr);
  184. printEmpStatistics (emp_totals_ptr, emp_minMax_ptr, theSize);
  185. }
  186.  
  187. // program end message
  188. printf ("\n\n *** End of Program *** \n");
  189. return 0;
  190. } // main
  191.  
  192. //**************************************************************
  193. // Function: getEmpData
  194. //
  195. // Purpose: Obtains input from user: employee name (first an last),
  196. // tax state, clock number, hourly wage, and hours worked
  197. // in a given week.
  198. //
  199. // Information in stored in a dynamically created linked
  200. // list for all employees.
  201. //
  202. // Parameters: void
  203. //
  204. // Returns:
  205. //
  206. // head_ptr - a pointer to the beginning of the dynamically
  207. // created linked list that contains the initial
  208. // input for each employee.
  209. //
  210. //**************************************************************
  211.  
  212. EMPLOYEE * getEmpData (void)
  213. {
  214. char answer[80]; // user prompt response
  215. int more_data = 1; // continue flag
  216. char value; // response char
  217. EMPLOYEE *current_ptr, *head_ptr;
  218.  
  219. // allocate first node
  220. head_ptr = (EMPLOYEE *) malloc (sizeof(EMPLOYEE));
  221. current_ptr = head_ptr;
  222.  
  223. while (more_data)
  224. {
  225. // read names
  226. printf ("\nEnter employee first name: ");
  227. scanf ("%s", current_ptr->empName.firstName);
  228. printf ("\nEnter employee last name: ");
  229. scanf ("%s", current_ptr->empName.lastName);
  230.  
  231. // read other data
  232. printf ("\nEnter employee two character tax state: ");
  233. scanf ("%s", current_ptr->taxState);
  234. printf("\nEnter employee clock number: ");
  235. scanf("%li", &current_ptr->clockNumber);
  236. printf("\nEnter employee hourly wage: ");
  237. scanf("%f", &current_ptr->wageRate);
  238. printf("\nEnter hours worked this week: ");
  239. scanf("%f", &current_ptr->hours);
  240.  
  241. // ask to add another
  242. printf("\nWould you like to add another employee? (y/n): ");
  243. scanf("%s", answer);
  244. value = toupper(answer[0]);
  245. if (value != 'Y')
  246. {
  247. current_ptr->next = NULL;
  248. more_data = 0;
  249. }
  250. else
  251. {
  252. current_ptr->next = (EMPLOYEE *) malloc (sizeof(EMPLOYEE));
  253. current_ptr = current_ptr->next;
  254. }
  255. } // while
  256.  
  257. return head_ptr;
  258.  
  259. } //getEmpData
  260.  
  261. //*************************************************************
  262. // Function: isEmployeeSize
  263. //
  264. // Purpose: Traverses the linked list and keeps a running count
  265. // on how many employees are currently in our list.
  266. //
  267. // Parameters:
  268. //
  269. // head_ptr - pointer to the initial node in our linked list
  270. //
  271. // Returns:
  272. //
  273. // theSize - the number of employees in our linked list
  274. //
  275. //**************************************************************
  276.  
  277. int isEmployeeSize (EMPLOYEE * head_ptr)
  278. {
  279. EMPLOYEE * current_ptr;
  280. int theSize = 0;
  281.  
  282. // check for at least one entry
  283. if (head_ptr->empName.firstName[0] != '\0')
  284. {
  285. for (current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  286. ++theSize;
  287. } // if
  288.  
  289. return theSize;
  290.  
  291. } // isEmployeeSize
  292.  
  293.  
  294.  
  295. //**************************************************************
  296. // Function: printHeader
  297. //
  298. // Purpose: Prints the initial table header information.
  299. //
  300. // Parameters: none
  301. //
  302. // Returns: void
  303. //
  304. //**************************************************************
  305.  
  306. void printHeader (void)
  307. {
  308. printf ("\n\n*** Pay Calculator ***\n");
  309. printf("\n--------------------------------------------------------------");
  310. printf("-------------------");
  311. printf("\nName Tax Clock# Wage Hours OT Gross State Fed Net");
  312. printf("\n State Pay Tax Tax Pay");
  313. printf("\n--------------------------------------------------------------");
  314. printf("-------------------");
  315.  
  316. } // printHeader
  317.  
  318.  
  319.  
  320. //*************************************************************
  321. // Function: printEmp
  322. //
  323. // Purpose: Prints out all the information for each employee
  324. // in a nice and orderly table format.
  325. //
  326. // Parameters:
  327. //
  328. // head_ptr - pointer to the beginning of our linked list
  329. //
  330. // Returns: void
  331. //
  332. //**************************************************************
  333.  
  334. void printEmp (EMPLOYEE * head_ptr)
  335. {
  336. char name[FIRST_NAME_SIZE + LAST_NAME_SIZE + 2];
  337. EMPLOYEE * current_ptr;
  338.  
  339. for (current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  340. {
  341. strcpy(name, current_ptr->empName.firstName);
  342. strcat(name, " ");
  343. strcat(name, current_ptr->empName.lastName);
  344. printf("\n%-20.20s %-2.2s %06li %5.2f %4.1f %4.1f %7.2f %6.2f %7.2f %8.2f",
  345. name,
  346. current_ptr->taxState,
  347. current_ptr->clockNumber,
  348. current_ptr->wageRate,
  349. current_ptr->hours,
  350. current_ptr->overtimeHrs,
  351. current_ptr->grossPay,
  352. current_ptr->stateTax,
  353. current_ptr->fedTax,
  354. current_ptr->netPay);
  355. } // for
  356.  
  357. } // printEmp
  358.  
  359.  
  360. //*************************************************************
  361. // Function: printEmpStatistics
  362. //
  363. // Purpose: Prints out the summary totals and averages of all
  364. // floating point value items for all employees
  365. // that have been processed. It also prints
  366. // out the min and max values.
  367. //
  368. // Parameters:
  369. //
  370. // emp_totals_ptr - pointer to a structure containing a running total
  371. // of all employee floating point items
  372. //
  373. // emp_minMax_ptr - pointer to a structure containing
  374. // the minimum and maximum values of all
  375. // employee floating point items
  376. //
  377. // tjeSize - the total number of employees processed, used
  378. // to check for zero or negative divide condition.
  379. //
  380. // Returns: void
  381. //
  382. //**************************************************************
  383.  
  384. void printEmpStatistics (TOTALS * emp_totals_ptr, MIN_MAX * emp_minMax_ptr, int theSize)
  385. {
  386. // separator
  387. printf("\n--------------------------------------------------------------");
  388. printf("-------------------");
  389.  
  390. // totals
  391. printf("\nTotals: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  392. emp_totals_ptr->total_wageRate,
  393. emp_totals_ptr->total_hours,
  394. emp_totals_ptr->total_overtimeHrs,
  395. emp_totals_ptr->total_grossPay,
  396. emp_totals_ptr->total_stateTax,
  397. emp_totals_ptr->total_fedTax,
  398. emp_totals_ptr->total_netPay);
  399.  
  400. // averages
  401. if (theSize > 0)
  402. {
  403. printf("\nAverages: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  404. emp_totals_ptr->total_wageRate/theSize,
  405. emp_totals_ptr->total_hours/theSize,
  406. emp_totals_ptr->total_overtimeHrs/theSize,
  407. emp_totals_ptr->total_grossPay/theSize,
  408. emp_totals_ptr->total_stateTax/theSize,
  409. emp_totals_ptr->total_fedTax/theSize,
  410. emp_totals_ptr->total_netPay/theSize);
  411. } // if
  412.  
  413. // min & max
  414. printf("\nMinimum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  415. emp_minMax_ptr->min_wageRate,
  416. emp_minMax_ptr->min_hours,
  417. emp_minMax_ptr->min_overtimeHrs,
  418. emp_minMax_ptr->min_grossPay,
  419. emp_minMax_ptr->min_stateTax,
  420. emp_minMax_ptr->min_fedTax,
  421. emp_minMax_ptr->min_netPay);
  422.  
  423. printf("\nMaximum: %5.2f %5.1f %5.1f %7.2f %6.2f %7.2f %8.2f",
  424. emp_minMax_ptr->max_wageRate,
  425. emp_minMax_ptr->max_hours,
  426. emp_minMax_ptr->max_overtimeHrs,
  427. emp_minMax_ptr->max_grossPay,
  428. emp_minMax_ptr->max_stateTax,
  429. emp_minMax_ptr->max_fedTax,
  430. emp_minMax_ptr->max_netPay);
  431.  
  432. // count
  433. printf ("\n\nThe total employees processed was: %i\n", theSize);
  434.  
  435.  
  436. } // printEmpStatistics
  437.  
  438.  
  439. //*************************************************************
  440. // Function: calcOvertimeHrs
  441. //
  442. // Purpose: Calculates the overtime hours worked by an employee
  443. // in a given week for each employee.
  444. //
  445. // Parameters:
  446. //
  447. // head_ptr - pointer to the beginning of our linked list
  448. //
  449. // Returns: void (the overtime hours gets updated by reference)
  450. //
  451. //**************************************************************
  452.  
  453.  
  454. void calcOvertimeHrs (EMPLOYEE * head_ptr)
  455. {
  456. for (EMPLOYEE * current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  457. current_ptr->overtimeHrs = CALC_OT_HOURS(current_ptr->hours);
  458.  
  459. } // calcOverTimeHrs
  460.  
  461. //*************************************************************
  462. // Function: calcGrossPay
  463. //
  464. // Purpose: Calculates the gross pay based on the the normal pay
  465. // and any overtime pay for a given week for each
  466. // employee.
  467. //
  468. // Parameters:
  469. //
  470. // head_ptr - pointer to the beginning of our linked list
  471. //
  472. // Returns: void (the gross pay gets updated by reference)
  473. //
  474. //**************************************************************
  475.  
  476. void calcGrossPay (EMPLOYEE * head_ptr)
  477. {
  478. for (EMPLOYEE * current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  479. {
  480. float normal = CALC_NORMAL_PAY(current_ptr->wageRate, current_ptr->hours, current_ptr->overtimeHrs);
  481. float otPay = CALC_OT_PAY(current_ptr->wageRate, current_ptr->overtimeHrs);
  482. current_ptr->grossPay = normal + otPay;
  483.  
  484. } // for
  485.  
  486. } // calcGrossPay
  487.  
  488.  
  489. //*************************************************************
  490. // Function: calcStateTax
  491. //
  492. // Purpose: Calculates the State Tax owed based on gross pay
  493. // for each employee. State tax rate is based on the
  494. // the designated tax state based on where the
  495. // employee is actually performing the work. Each
  496. // state decides their tax rate.
  497. //
  498. // Parameters:
  499. //
  500. // head_ptr - pointer to the beginning of our linked list
  501. //
  502. // Returns: void (the state tax gets updated by reference)
  503. //
  504. //**************************************************************
  505.  
  506.  
  507. void calcStateTax (EMPLOYEE * head_ptr)
  508. {
  509. for (EMPLOYEE * current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  510. {
  511. if (islower(current_ptr->taxState[0])) current_ptr->taxState[0] = toupper(current_ptr->taxState[0]);
  512. if (islower(current_ptr->taxState[1])) current_ptr->taxState[1] = toupper(current_ptr->taxState[1]);
  513.  
  514. if (strcmp(current_ptr->taxState, "MA") == 0)
  515. current_ptr->stateTax = CALC_STATE_TAX(current_ptr->grossPay, MA_TAX_RATE);
  516. else if (strcmp(current_ptr->taxState, "VT") == 0)
  517. current_ptr->stateTax = CALC_STATE_TAX(current_ptr->grossPay, VT_TAX_RATE);
  518. else if (strcmp(current_ptr->taxState, "NH") == 0)
  519. current_ptr->stateTax = CALC_STATE_TAX(current_ptr->grossPay, NH_TAX_RATE);
  520. else if (strcmp(current_ptr->taxState, "CA") == 0)
  521. current_ptr->stateTax = CALC_STATE_TAX(current_ptr->grossPay, CA_TAX_RATE);
  522. else
  523. current_ptr->stateTax = CALC_STATE_TAX(current_ptr->grossPay, DEFAULT_STATE_TAX_RATE);
  524. } // for
  525.  
  526. } // calcStateTax
  527.  
  528.  
  529. //*************************************************************
  530. // Function: calcFedTax
  531. //
  532. // Purpose: Calculates the Federal Tax owed based on the gross
  533. // pay for each employee
  534. //
  535. // Parameters:
  536. //
  537. // head_ptr - pointer to the beginning of our linked list
  538. //
  539. // Returns: void (the federal tax gets updated by reference)
  540. //
  541. //**************************************************************
  542.  
  543. void calcFedTax (EMPLOYEE * head_ptr)
  544. {
  545. for (EMPLOYEE * current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  546. current_ptr->fedTax = CALC_FED_TAX(current_ptr->grossPay, FED_TAX_RATE);
  547.  
  548. } // calcFedTax
  549.  
  550.  
  551.  
  552. //*************************************************************
  553. // Function: calcNetPay
  554. //
  555. // Purpose: Calculates the net pay as the gross pay minus any
  556. // state and federal taxes owed for each employee.
  557. // Essentially, their "take home" pay.
  558. //
  559. // Parameters:
  560. //
  561. // head_ptr - pointer to the beginning of our linked list
  562. //
  563. // Returns: void (the net pay gets updated by reference)
  564. //
  565. //**************************************************************
  566.  
  567.  
  568. void calcNetPay (EMPLOYEE * head_ptr)
  569. {
  570. for (EMPLOYEE * current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  571. current_ptr->netPay = CALC_NET_PAY(current_ptr->grossPay, current_ptr->stateTax, current_ptr->fedTax);
  572.  
  573. } // calcNetpay
  574.  
  575.  
  576. //*************************************************************
  577. // Function: calcEmployeeTotals
  578. //
  579. // Purpose: Performs a running total (sum) of each employee
  580. // floating point member item stored in our linked list
  581. //
  582. // Parameters:
  583. //
  584. // head_ptr - pointer to the beginning of our linked list
  585. // emp_totals_ptr - pointer to a structure containing the
  586. // running totals of each floating point
  587. // member for all employees in our linked
  588. // list
  589. //
  590. // Returns:
  591. //
  592. // void (the employeeTotals structure gets updated by reference)
  593. //
  594. //**************************************************************
  595.  
  596. void calcEmployeeTotals (EMPLOYEE * head_ptr, TOTALS * emp_totals_ptr)
  597. {
  598. for (EMPLOYEE * current_ptr = head_ptr; current_ptr; current_ptr = current_ptr->next)
  599. {
  600. emp_totals_ptr->total_wageRate += current_ptr->wageRate;
  601. emp_totals_ptr->total_hours += current_ptr->hours;
  602. emp_totals_ptr->total_overtimeHrs+= current_ptr->overtimeHrs;
  603. emp_totals_ptr->total_grossPay += current_ptr->grossPay;
  604. emp_totals_ptr->total_stateTax += current_ptr->stateTax;
  605. emp_totals_ptr->total_fedTax += current_ptr->fedTax;
  606. emp_totals_ptr->total_netPay += current_ptr->netPay;
  607.  
  608. } // for
  609.  
  610. } // calcEmployeeTotals
  611.  
  612.  
  613. //*************************************************************
  614. // Function: calcEmployeeMinMax
  615. //
  616. // Purpose: Accepts various floating point values from an
  617. // employee and adds to a running update of min
  618. // and max values
  619. //
  620. // Parameters:
  621. //
  622. // head_ptr - pointer to the beginning of our linked list
  623. // emp_minMax_ptr - pointer to the min/max structure
  624. //
  625. // Returns:
  626. //
  627. // void (employeeMinMax structure updated by reference)
  628. //
  629. //**************************************************************
  630.  
  631.  
  632. void calcEmployeeMinMax (EMPLOYEE * head_ptr, MIN_MAX * emp_minMax_ptr)
  633. {
  634. EMPLOYEE * current_ptr = head_ptr;
  635. // initialize with first employee
  636. emp_minMax_ptr->min_wageRate = emp_minMax_ptr->max_wageRate = current_ptr->wageRate;
  637. emp_minMax_ptr->min_hours = emp_minMax_ptr->max_hours = current_ptr->hours;
  638. emp_minMax_ptr->min_overtimeHrs = emp_minMax_ptr->max_overtimeHrs = current_ptr->overtimeHrs;
  639. emp_minMax_ptr->min_grossPay = emp_minMax_ptr->max_grossPay = current_ptr->grossPay;
  640. emp_minMax_ptr->min_stateTax = emp_minMax_ptr->max_stateTax = current_ptr->stateTax;
  641. emp_minMax_ptr->min_fedTax = emp_minMax_ptr->max_fedTax = current_ptr->fedTax;
  642. emp_minMax_ptr->min_netPay = emp_minMax_ptr->max_netPay = current_ptr->netPay;
  643.  
  644. // traverse remaining
  645. current_ptr = current_ptr->next;
  646. for (; current_ptr; current_ptr = current_ptr->next)
  647. {
  648. emp_minMax_ptr->min_wageRate = CALC_MIN(current_ptr->wageRate, emp_minMax_ptr->min_wageRate);
  649. emp_minMax_ptr->max_wageRate = CALC_MAX(current_ptr->wageRate, emp_minMax_ptr->max_wageRate);
  650.  
  651. emp_minMax_ptr->min_hours = CALC_MIN(current_ptr->hours, emp_minMax_ptr->min_hours);
  652. emp_minMax_ptr->max_hours = CALC_MAX(current_ptr->hours, emp_minMax_ptr->max_hours);
  653.  
  654. emp_minMax_ptr->min_overtimeHrs = CALC_MIN(current_ptr->overtimeHrs, emp_minMax_ptr->min_overtimeHrs);
  655. emp_minMax_ptr->max_overtimeHrs = CALC_MAX(current_ptr->overtimeHrs, emp_minMax_ptr->max_overtimeHrs);
  656.  
  657. emp_minMax_ptr->min_grossPay = CALC_MIN(current_ptr->grossPay, emp_minMax_ptr->min_grossPay);
  658. emp_minMax_ptr->max_grossPay = CALC_MAX(current_ptr->grossPay, emp_minMax_ptr->max_grossPay);
  659.  
  660. emp_minMax_ptr->min_stateTax = CALC_MIN(current_ptr->stateTax, emp_minMax_ptr->min_stateTax);
  661. emp_minMax_ptr->max_stateTax = CALC_MAX(current_ptr->stateTax, emp_minMax_ptr->max_stateTax);
  662.  
  663. emp_minMax_ptr->min_fedTax = CALC_MIN(current_ptr->fedTax, emp_minMax_ptr->min_fedTax);
  664. emp_minMax_ptr->max_fedTax = CALC_MAX(current_ptr->fedTax, emp_minMax_ptr->max_fedTax);
  665.  
  666. emp_minMax_ptr->min_netPay = CALC_MIN(current_ptr->netPay, emp_minMax_ptr->min_netPay);
  667. emp_minMax_ptr->max_netPay = CALC_MAX(current_ptr->netPay, emp_minMax_ptr->max_netPay);
  668.  
  669. } // for
  670.  
  671. } // calcEmployeeMinMax
  672.  
Success #stdin #stdout 0.01s 5288KB
stdin
Connie
Cobol
MA
98401
10.60
51.0
Y
Mary
Apl
NH
526488
9.75
42.5
Y
Frank
Fortran
VT
765349
10.50
37.0
Y
Jeff
Ada
NY
34645
12.25
45
Y
Anton
Pascal
CA
127615
8.35
40.0
N
stdout
Enter employee first name: 
Enter employee last name: 
Enter employee two character tax state: 
Enter employee clock number: 
Enter employee hourly wage: 
Enter hours worked this week: 
Would you like to add another employee? (y/n): 
Enter employee first name: 
Enter employee last name: 
Enter employee two character tax state: 
Enter employee clock number: 
Enter employee hourly wage: 
Enter hours worked this week: 
Would you like to add another employee? (y/n): 
Enter employee first name: 
Enter employee last name: 
Enter employee two character tax state: 
Enter employee clock number: 
Enter employee hourly wage: 
Enter hours worked this week: 
Would you like to add another employee? (y/n): 
Enter employee first name: 
Enter employee last name: 
Enter employee two character tax state: 
Enter employee clock number: 
Enter employee hourly wage: 
Enter hours worked this week: 
Would you like to add another employee? (y/n): 
Enter employee first name: 
Enter employee last name: 
Enter employee two character tax state: 
Enter employee clock number: 
Enter employee hourly wage: 
Enter hours worked this week: 
Would you like to add another employee? (y/n): 

*** 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

The total employees processed was: 5


 *** End of Program ***