fork download
  1. //*******************************************************
  2. //
  3. // Assignment 3 - Conditionals
  4. //
  5. // Name: Seth Hin
  6. //
  7. // Class: C Programming, Spring 2026
  8. //
  9. // Date: February 10, 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. // declared constants
  20.  
  21. #define STD_HOURS 40.0 // standard work week without overtime
  22. #define NUM_EMPLOYEES 5 // number of emoployeees to process
  23. #define OT_RATE 1.5 // overtime rate after 40 hours
  24.  
  25.  
  26. int main()
  27. {
  28.  
  29. int clockNumber; // Employee clock number
  30. float grossPay; // The weekly gross pay which is the normalPay + any overtimePay
  31. float hours; // Total hours worked in a week
  32. float normalPay; // Standard weekly normal pay without overtime
  33. float overtimeHrs; // Any hours worked past the normal scheduled work week
  34. float overtimePay; // Additional overtime pay for any overtime hours worked
  35. float wageRate; // Hourly wage for an employee
  36.  
  37. printf ("\n*** Pay Calculator ***");
  38.  
  39. // process each employee one at a time
  40. for (int i = 0; i < NUM_EMPLOYEES; i++) {
  41.  
  42. // process each employee
  43. printf("\n\nEnter clock number: ");
  44. scanf("%d", &clockNumber);
  45.  
  46. // process each employee for the wage rate
  47. printf("\nEnter wage rate: ");
  48. scanf("%f", &wageRate);
  49.  
  50. // process each employee for number of hours worked
  51. printf("\nEnter number of hours worked: ");
  52. scanf("%f", &hours);
  53.  
  54. // initialize values
  55.  
  56. overtimePay = 0.0;
  57. overtimeHrs = 0.0;
  58. normalPay = 0.0;
  59.  
  60. // Calculate the overtime hours, normal pay, and overtime pay
  61.  
  62. if (hours > STD_HOURS) {
  63. overtimeHrs = hours - STD_HOURS;
  64. normalPay = wageRate * STD_HOURS;
  65. overtimePay = (OT_RATE * wageRate) * overtimeHrs;
  66. }
  67.  
  68. else // no overtime
  69. {
  70. normalPay = wageRate * hours;
  71. }
  72.  
  73. // Calculate the gross pay with normal pay and any additional overtime pay
  74.  
  75. grossPay = normalPay + overtimePay;
  76.  
  77. // Print out information on the current employee(s)
  78.  
  79. printf("\n\nClock# Wage Hours OT Gross\n");
  80. printf("------------------------------------------------\n");
  81. printf("%06d %5.2f %5.1f %5.1f %8.2f\n",
  82. clockNumber, wageRate, hours, overtimeHrs, grossPay);
  83.  
  84.  
  85. } // end of for loop
  86.  
  87. return 0;
  88. }
Success #stdin #stdout 0s 5308KB
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