fork download
  1. //*******************************************************
  2. //
  3. // Assignment 3 - Conditionals
  4. //
  5. // Name: John Semenuk
  6. //
  7. // Class: C Programming, Spring 2026
  8. //
  9. // Date: February 14, 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 STD_HOURS 40.0
  21. #define NUM_EMPLOYEES 5
  22. #define OT_RATE 1.5 // Overtime pay rate
  23.  
  24. int main()
  25. {
  26. int clockNumber;
  27. float grossPay;
  28. float hours;
  29. float normalPay;
  30. float overtimeHrs;
  31. float overtimePay;
  32. float wageRate;
  33.  
  34. printf ("\n*** Pay Calculator ***");
  35.  
  36. // Process each employee
  37. for (int i = 0; i < NUM_EMPLOYEES; i++) {
  38.  
  39. printf("\n\nEnter clock number: ");
  40. scanf("%d", &clockNumber);
  41.  
  42. printf("\nEnter wage rate: ");
  43. scanf("%f", &wageRate);
  44.  
  45. printf("\nEnter number of hours worked: ");
  46. scanf("%f", &hours);
  47.  
  48. grossPay = 0;
  49. overtimeHrs = 0;
  50. overtimePay = 0;
  51. normalPay = 0;
  52.  
  53. // Calculate the overtime hours, normal pay, and overtime pay
  54. if (hours > STD_HOURS)
  55. {
  56. overtimeHrs = hours - STD_HOURS;
  57. normalPay = STD_HOURS * wageRate;
  58. overtimePay = overtimeHrs * wageRate * OT_RATE;
  59. }
  60. else
  61. {
  62. normalPay = hours * wageRate;
  63. overtimePay = 0;
  64. overtimeHrs = 0;
  65. }
  66.  
  67. // Calculate gross pay
  68. grossPay = normalPay + overtimePay;
  69.  
  70. // Print out information on the current employee
  71. printf("\n\nClock# Wage Hours OT Gross\n");
  72. printf("------------------------------------------------\n");
  73. printf("%06d %5.2f %5.1f %5.1f %8.2f\n",
  74. clockNumber, wageRate, hours, overtimeHrs, grossPay);
  75. }
  76.  
  77. return 0;
  78. }
  79.  
  80.  
Success #stdin #stdout 0.01s 5288KB
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 clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OT      Gross
------------------------------------------------
098401 10.60  51.0  11.0   598.90


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OT      Gross
------------------------------------------------
526488  9.75  42.5   2.5   426.56


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OT      Gross
------------------------------------------------
765349 10.50  37.0   0.0   388.50


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OT      Gross
------------------------------------------------
034645 12.25  45.0   5.0   581.88


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OT      Gross
------------------------------------------------
127615  8.35   0.0   0.0     0.00