fork download
  1. #include <stdio.h>
  2.  
  3. #define SIZE 5 // Number of employees to process
  4. #define STD_HOURS 40.0 // Standard work hours before overtime
  5. #define OT_RATE 1.5 // Overtime rate multiplier
  6.  
  7. int main() {
  8. int i;
  9. int clockNumber;
  10. float wage, hours, overtimeHours, grossPay;
  11. float regularPay, overtimePay;
  12.  
  13. printf("***Pay Calculator***\n\n");
  14.  
  15. for (i = 1; i <= SIZE; ++i) {
  16. // Input section
  17. printf("Enter Employee's Clock #: ");
  18. scanf("%d", &clockNumber);
  19.  
  20. printf("Enter hourly wage: ");
  21. scanf("%f", &wage);
  22.  
  23. printf("Enter number of hours worked: ");
  24. scanf("%f", &hours);
  25.  
  26. // Calculation section
  27. if (hours > STD_HOURS) {
  28. overtimeHours = hours - STD_HOURS;
  29. } else {
  30. overtimeHours = 0.0;
  31. }
  32.  
  33. regularPay = (hours > STD_HOURS ? STD_HOURS : hours) * wage;
  34. overtimePay = overtimeHours * wage * OT_RATE;
  35. grossPay = regularPay + overtimePay;
  36.  
  37. // Output section
  38. printf("\n------------------------------------------------\n");
  39. printf("Clock# Wage Hours OT Gross\n");
  40. printf("------------------------------------------------\n");
  41. printf("%06d %5.2f %5.1f %5.1f %8.2f\n\n",
  42. clockNumber, wage, hours, overtimeHours, grossPay);
  43. }
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5324KB
stdin
5
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
------------------------------------------------
000005 98401.00  10.6   0.0 1043050.62

Enter Employee's Clock #: Enter hourly wage: Enter number of hours worked: 
------------------------------------------------
Clock#  Wage  Hours  OT     Gross
------------------------------------------------
000051  0.00 526488.0 526448.0     0.00

Enter Employee's Clock #: Enter hourly wage: Enter number of hours worked: 
------------------------------------------------
Clock#  Wage  Hours  OT     Gross
------------------------------------------------
000009  0.75  42.5   2.5    32.81

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