fork download
  1. //*******************************************************
  2. //
  3. // Assignment 4 - Arrays
  4. //
  5. // Name: Toddra Pamplin
  6. //
  7. // Class: C Programming, Spring 2026
  8. //
  9. // Date: 2/22/2026
  10. //
  11. // Description: Program which determines overtime and
  12. // gross pay for a set of employees with outputs sent
  13. // to standard output (the screen).
  14. //
  15. //********************************************************
  16.  
  17. #include <stdio.h>
  18.  
  19. // constants to use
  20. #define SIZE 5 // number of employees to process
  21. #define STD_HOURS 40.0 // normal work week hours before overtime
  22. #define OT_RATE 1.5 // time and half overtime setting
  23.  
  24. int main()
  25. {
  26. // unique employee identifier
  27. long int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615};
  28.  
  29. float grossPay[SIZE];
  30. float hours[SIZE];
  31. int i;
  32. float normalPay[SIZE];
  33. float overtimeHrs[SIZE];
  34. float overtimePay[SIZE];
  35.  
  36. // hourly pay for each employee
  37. float wageRate[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};
  38.  
  39. printf("\n*** Pay Calculator ***\n\n");
  40.  
  41. // Process each employee one at a time
  42. for (i = 0; i < SIZE; i++)
  43. {
  44. // Prompt and read hours worked
  45. scanf("%f", &hours[i]);
  46.  
  47. if (hours[i] >= STD_HOURS)
  48. {
  49. overtimeHrs[i] = hours[i] - STD_HOURS;
  50.  
  51. normalPay[i] = STD_HOURS * wageRate[i];
  52. overtimePay[i] = overtimeHrs[i] * wageRate[i] * OT_RATE;
  53. }
  54. else // no overtime
  55. {
  56. overtimeHrs[i] = 0;
  57.  
  58. normalPay[i] = hours[i] * wageRate[i];
  59. overtimePay[i] = 0;
  60. }
  61.  
  62. // Calculate Gross Pay
  63. grossPay[i] = normalPay[i] + overtimePay[i];
  64. }
  65.  
  66. // Print table header
  67. printf("\n%-10s %-10s %-10s %-12s %-12s %-12s\n",
  68. "Clock#", "Wage", "Hours", "Normal Pay", "OT Pay", "Gross Pay");
  69.  
  70. printf("---------------------------------------------------------------------\n");
  71.  
  72. // Print employee information
  73. for (i = 0; i < SIZE; i++)
  74. {
  75. printf("%-10ld %-10.2f %-10.2f %-12.2f %-12.2f %-12.2f\n",
  76. clockNumber[i], wageRate[i], hours[i], normalPay[i], overtimePay[i], grossPay[i]);
  77. }
  78.  
  79. return 0;
  80. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
*** Pay Calculator ***


Clock#     Wage       Hours      Normal Pay   OT Pay       Gross Pay   
---------------------------------------------------------------------
98401      10.60      1833805068663595619561701900288.00 424.00       29157501558891826042734399979520.00 29157501558891826042734399979520.00
526488     9.75       0.00       0.00         0.00         0.00        
765349     10.50      0.00       0.00         0.00         0.00        
34645      12.25      0.00       0.00         0.00         0.00        
127615     8.35       0.00       0.00         0.00         0.00