fork download
  1. //*******************************************************
  2. //
  3. // Assignment 4 - Arrays
  4. //
  5. // Name: Rose Samedi
  6. //
  7. // Class: C Programming, Fall 2025
  8. //
  9. // Date: 10/5/2025
  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.  
  23. int main()
  24. {
  25.  
  26.  
  27. // Declare variables needed for the program
  28. // Recommend an array for clock, wage, hours,
  29. // ... and overtime hours and gross.
  30. // Recommend arrays also for normal pay and overtime pay
  31. // It is OK to pre-fill clock and wage values ... or you can prompt for them
  32. // unique employee identifier
  33. long int clockNumber [SIZE] = {98401, 526488, 765349, 34645, 127615};
  34.  
  35. float grossPay [SIZE]; // weekly gross pay - normal pay + overtime pay
  36. float hours [SIZE]; // hours worked in a given week
  37. int i; // loop and array index
  38. float normalPay [SIZE]; // normal weekly pay without any overtime
  39. float overtimeHrs[SIZE]; // overtime hours worked in a given week
  40. float overtimePay [SIZE]; // overtime pay for a given week
  41.  
  42. // hourly pay for each employee
  43. float wageRate [SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35};
  44. printf ("\n*** Pay Calculator ***\n\n");
  45.  
  46. // Process each employee one at a time
  47. for (i = 0; i < SIZE; i++)
  48. {
  49.  
  50. // TODO - Prompt and Read in hours worked for employee
  51.  
  52. // Calculate overtime and gross pay for employee
  53. if (hours[i] >= STD_HOURS)
  54. {
  55. overtimeHrs[i] = hours[i] - STD_HOURS;
  56. // TODO: Calculate arrays normalPay and overtimePay with overtime
  57.  
  58. }
  59. else // no OT
  60. {
  61. overtimeHrs[i] = 0;
  62. // TODO: Calculate arrays normalPay and overtimePay without overtime
  63.  
  64. }
  65.  
  66. // Calculate Gross Pay
  67. grossPay[i] = normalPay[i] + overtimePay[i];
  68. }
  69.  
  70. // TODO: Print a nice table header
  71. // Now that we have all the information in our arrays, we can
  72. // Access each employee and print to screen or file
  73. for (i = 0; i < SIZE; i++)
  74. {
  75. // TODO: Print employee information from your arrays
  76. }
  77.  
  78. return(0);
  79. }
  80.  
Success #stdin #stdout 0s 5320KB
stdin
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
127617  8.35  0.0  0.0   0.00
stdout
*** Pay Calculator ***