fork download
  1. //*******************************************************
  2. // Assignment 3 - Conditionals
  3. //
  4. // Name: Carlos Dominguez
  5. //
  6. // Class: C Programming, Spring 2026
  7. //
  8. // Date: 02/09/2026 ------------------- is winter over?
  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. #include <stdio.h>
  16.  
  17. // Declare constants
  18. #define STD_HOURS 40.0 // constant standard hours
  19. #define NUM_EMPLOYEES 5 // constant number of employees
  20. #define OT_RATE 1.5 // constant for overtime multiplier
  21.  
  22. int main()
  23. {
  24. int clockNumber; // Employee clock number
  25. float grossPay; // The weekly gross pay which is the normalPay + any overtimePay
  26. float hours; // Total hours worked in a week
  27. float normalPay; // Standard weekly normal pay without overtime
  28. float overtimeHrs; // Any hours worked past the normal scheduled work week
  29. float overtimePay; // Additional overtime pay for any overtime hours worked
  30. float wageRate; // Hourly wage for an employee
  31.  
  32.  
  33. printf ("\n*** Pay Calculator ***");
  34.  
  35. // BEGIN employee-processing loop
  36. // This loop repeats once for each employee and handles:
  37. // - Input collection
  38. // - Overtime calculation
  39. // - Pay calculations
  40. // - Output
  41. // -------------------------------------------------------------
  42.  
  43. for (int i = 0; i < NUM_EMPLOYEES; i++) {
  44.  
  45. printf("\n\nEnter clock number: ");
  46. scanf("%d", &clockNumber);
  47.  
  48. printf("\nEnter wage rate: ");
  49. scanf("%f", &wageRate);
  50.  
  51. printf("\nEnter number of hours worked: ");
  52. scanf("%f", &hours);
  53.  
  54. if (hours > STD_HOURS) {
  55. // Calculate overtime hours and pay
  56. overtimeHrs = hours - STD_HOURS;
  57. normalPay = STD_HOURS * wageRate;
  58. overtimePay = overtimeHrs * wageRate * OT_RATE;
  59. } else {
  60. // No overtime — all hours are normal hours
  61. overtimeHrs = 0.0;
  62. normalPay = hours * wageRate;
  63. overtimePay = 0.0;
  64. }
  65. // Total gross pay calculation
  66. grossPay = normalPay + overtimePay;
  67.  
  68. // Display results
  69. printf("\n\nClock# Wage Hours overtimeHrs normalPay overtimePay Gross\n");
  70. printf("-------------------------------------------------------------------------\n");
  71. printf("%06d %5.2f %5.1f %5.1f %8.2f %8.2f %8.2f\n",
  72. clockNumber, wageRate, hours, overtimeHrs,
  73. normalPay, overtimePay, grossPay);
  74. }
  75. //---------------------------------------------------------------------
  76. // END employee-processing loop
  77.  
  78. return 0; // End program
  79. }
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 clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock#   Wage  Hours  overtimeHrs  normalPay  overtimePay   Gross
-------------------------------------------------------------------------
098401   10.60   51.0     11.0        424.00     174.90    598.90


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

Clock#   Wage  Hours  overtimeHrs  normalPay  overtimePay   Gross
-------------------------------------------------------------------------
526488    9.75   42.5      2.5        390.00      36.56    426.56


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

Clock#   Wage  Hours  overtimeHrs  normalPay  overtimePay   Gross
-------------------------------------------------------------------------
765349   10.50   37.0      0.0        388.50       0.00    388.50


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

Clock#   Wage  Hours  overtimeHrs  normalPay  overtimePay   Gross
-------------------------------------------------------------------------
034645   12.25   45.0      5.0        490.00      91.88    581.88


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

Clock#   Wage  Hours  overtimeHrs  normalPay  overtimePay   Gross
-------------------------------------------------------------------------
127615    8.35    0.0      0.0          0.00       0.00      0.00