fork download
  1. //*******************************************************
  2. //
  3. // Assignment 3 - Conditionals
  4. //
  5. // Name: Samuel Morris
  6. //
  7. // Class: C Programming, Summer 2025
  8. //
  9. // Date: June 16, 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
  20. #define STD_HOURS 40.0
  21. #define OT_RATE 1.5
  22. #define NUM_EMPLOYEES 5
  23.  
  24. int main()
  25. {
  26. int i;
  27. int clockNumber;
  28. float hours;
  29. float wage;
  30. float overtimeHours;
  31. float normalPay;
  32. float overtimePay;
  33. float grossPay;
  34.  
  35. printf("*** Pay Calculator ***\n");
  36.  
  37. for (i = 0; i < NUM_EMPLOYEES; ++i)
  38. {
  39. // Input
  40. printf("Enter Employee's Clock #:\n");
  41. scanf("%d", &clockNumber);
  42. printf("Enter hourly wage:\n");
  43. scanf("%f", &wage);
  44. printf("Enter number of hours worked:\n");
  45. scanf("%f", &hours);
  46.  
  47. // Overtime calculation
  48. if (hours > STD_HOURS)
  49. overtimeHours = hours - STD_HOURS;
  50. else
  51. overtimeHours = 0.0;
  52.  
  53. // Normal and Overtime Pay
  54. normalPay = wage * (hours > STD_HOURS ? STD_HOURS : hours);
  55. overtimePay = (wage * OT_RATE) * overtimeHours;
  56. grossPay = normalPay + overtimePay;
  57.  
  58. // Output formatting
  59. printf("-----------------------------------------------\n");
  60. printf("Clock# Wage Hours OT Gross\n");
  61. printf("-----------------------------------------------\n");
  62. printf("%06d %5.2f %5.1f %4.1f %7.2f\n\n",
  63. clockNumber, wage, hours, overtimeHours, grossPay);
  64. }
  65.  
  66. return 0;
  67. }
Success #stdin #stdout 0s 5316KB
stdin
98401  10.60  51.0   
526488  9.75  42.5   
765349 10.50  37.0   
34645  12.25  45.0   
127615  8.35   0.0  
stdout
*** Pay Calculator ***
Enter Employee's Clock #:
Enter hourly wage:
Enter number of hours worked:
-----------------------------------------------
Clock#   Wage   Hours  OT     Gross
-----------------------------------------------
098401  10.60   51.0  11.0    598.90

Enter Employee's Clock #:
Enter hourly wage:
Enter number of hours worked:
-----------------------------------------------
Clock#   Wage   Hours  OT     Gross
-----------------------------------------------
526488   9.75   42.5   2.5    426.56

Enter Employee's Clock #:
Enter hourly wage:
Enter number of hours worked:
-----------------------------------------------
Clock#   Wage   Hours  OT     Gross
-----------------------------------------------
765349  10.50   37.0   0.0    388.50

Enter Employee's Clock #:
Enter hourly wage:
Enter number of hours worked:
-----------------------------------------------
Clock#   Wage   Hours  OT     Gross
-----------------------------------------------
034645  12.25   45.0   5.0    581.88

Enter Employee's Clock #:
Enter hourly wage:
Enter number of hours worked:
-----------------------------------------------
Clock#   Wage   Hours  OT     Gross
-----------------------------------------------
127615   8.35    0.0   0.0      0.00