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