fork download
  1. //
  2. // Assignment 4 - Arrays
  3. //
  4. // Name: Henri Biqiku
  5. //
  6. // Class: C Programming, Fall 2026
  7. //
  8. // Date: Oct 4, 2026
  9. //
  10. // Description: Program which determines overtime and
  11. // gross pay for a set of employees with outputs sent
  12. // to standard output (the screen).
  13. //
  14. //********************************************************
  15.  
  16. #include <stdio.h>
  17.  
  18. // Constants
  19. #define SIZE 5
  20. #define STD_HOURS 40.0
  21. #define OT_RATE 1.5
  22.  
  23. int main()
  24. {
  25. // Unique employee identifier
  26. long int clockNumber[SIZE] = {
  27. 98401, 526488, 765349, 34645, 127615
  28. };
  29.  
  30. // Hourly wage for each employee
  31. float wageRate[SIZE] = {
  32. 10.60, 9.75, 10.50, 12.25, 8.35
  33. };
  34.  
  35. // Arrays for hours, overtime, and gross pay
  36. float hours[SIZE];
  37. float overtimeHrs[SIZE];
  38. float grossPay[SIZE];
  39.  
  40. // Variables used for calculations
  41. float normalPay;
  42. float overtimePay;
  43.  
  44. int i;
  45.  
  46. printf("\n\t*** Pay Calculator ***\n\n");
  47.  
  48. // Read hours and calculate overtime and gross pay
  49. for (i = 0; i < SIZE; i++)
  50. {
  51. printf("Enter hours worked for employee %ld: ", clockNumber[i]);
  52. scanf("%f", &hours[i]);
  53.  
  54. if (hours[i] > STD_HOURS)
  55. {
  56. overtimeHrs[i] = hours[i] - STD_HOURS;
  57.  
  58. normalPay = wageRate[i] * STD_HOURS;
  59.  
  60. overtimePay = wageRate[i] * OT_RATE * overtimeHrs[i];
  61.  
  62. grossPay[i] = normalPay + overtimePay;
  63. }
  64. else
  65. {
  66. overtimeHrs[i] = 0.0;
  67.  
  68. normalPay = wageRate[i] * hours[i];
  69.  
  70. overtimePay = 0.0;
  71.  
  72. grossPay[i] = normalPay;
  73. }
  74. }
  75.  
  76. // Print report
  77. printf("\n");
  78. printf("--------------------------------------------------------------------------\n");
  79. printf(" Clock# Wage Hours OT Gross\n");
  80. printf("--------------------------------------------------------------------------\n");
  81.  
  82. for (i = 0; i < SIZE; i++)
  83. {
  84. printf(" %06ld %5.2f %5.1f %6.1f %10.2f\n",
  85. clockNumber[i],
  86. wageRate[i],
  87. hours[i],
  88. overtimeHrs[i],
  89. grossPay[i]);
  90. }
  91.  
  92. printf("--------------------------------------------------------------------------\n");
  93.  
  94. return 0;
  95. }
Success #stdin #stdout 0.01s 5324KB
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#   Wage  Hours    OT       Gross
--------------------------------------------------------------------------
    098401  10.60   51.0    11.0      598.90
    526488   9.75   42.5     2.5      426.56
    765349  10.50   37.0     0.0      388.50
    034645  12.25   45.0     5.0      581.88
    127615   8.35    0.0     0.0        0.00
--------------------------------------------------------------------------