fork download
  1. //*******************************************************
  2. //
  3. // Assignment 4 - Arrays
  4. //
  5. // Name: John Semenuk
  6. //
  7. // Class: C Programming, Spring 2026
  8. //
  9. // Date: 22-Feb-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. // Declare constants
  20. #define SIZE 5
  21. #define STD_HOURS 40.0
  22. #define OT_RATE 1.5
  23.  
  24. int main( )
  25. {
  26.  
  27. // Declare arrays
  28. long int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615};
  29. float wageRate[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};
  30. float hours[SIZE];
  31. float normalPay[SIZE];
  32. float overtimeHrs[SIZE];
  33. float overtimePay[SIZE];
  34. float grossPay[SIZE];
  35.  
  36. int i;
  37.  
  38. printf("\n*** Pay Calculator ***\n\n");
  39.  
  40. // Input hours and calculate pay
  41. for (i = 0; i < SIZE; i++)
  42. {
  43.  
  44. printf("Enter hours worked for employee %ld: ", clockNumber[i]);
  45. scanf("%f", &hours[i]);
  46.  
  47. if (hours[i] > STD_HOURS)
  48. {
  49. overtimeHrs[i] = hours[i] - STD_HOURS;
  50. normalPay[i] = STD_HOURS * wageRate[i];
  51. overtimePay[i] = overtimeHrs[i] * wageRate[i] * OT_RATE;
  52. }
  53. else
  54. {
  55. overtimeHrs[i] = 0.0;
  56. normalPay[i] = hours[i] * wageRate[i];
  57. overtimePay[i] = 0.0;
  58. }
  59.  
  60. grossPay[i] = normalPay[i] + overtimePay[i];
  61.  
  62. }
  63.  
  64. // Print report header
  65. printf("\n%-10s %-10s %-10s %-10s %-10s %-10s\n",
  66. "Clock #", "Hours", "Rate", "Normal", "OT Hrs", "Gross");
  67.  
  68. printf("------------------------------------------------------------\n");
  69.  
  70. // Print employee data
  71. for (i = 0; i < SIZE; i++)
  72. {
  73.  
  74. printf("%-10ld %-10.2f $%-9.2f $%-9.2f %-10.2f $%-9.2f\n",
  75. clockNumber[i],
  76. hours[i],
  77. wageRate[i],
  78. normalPay[i],
  79. overtimeHrs[i],
  80. grossPay[i]);
  81.  
  82. }
  83.  
  84. return 0;
  85.  
  86. }
  87.  
Success #stdin #stdout 0s 5308KB
stdin
51.0
42.5
37.0
45.0
0.0
stdout
*** Pay Calculator ***

Enter hours worked for employee 98401: Enter hours worked for employee 526488: Enter hours worked for employee 765349: Enter hours worked for employee 34645: Enter hours worked for employee 127615: 
Clock #    Hours      Rate       Normal     OT Hrs     Gross     
------------------------------------------------------------
98401      51.00      $10.60     $424.00    11.00      $598.90   
526488     42.50      $9.75      $390.00    2.50       $426.56   
765349     37.00      $10.50     $388.50    0.00       $388.50   
34645      45.00      $12.25     $490.00    5.00       $581.88   
127615     0.00       $8.35      $0.00      0.00       $0.00