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