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