fork download
  1. /*George Notini
  2. Assignment 3
  3. C Programming, Summer 2025
  4. 06/13/25
  5. Program calculating gross pay including overtime*/
  6. #include <stdio.h>
  7.  
  8.  
  9. #define employeesWorked 5
  10. #define standardHours 40
  11. int main()
  12. {
  13. int idx;/*loop index*/
  14. int clockNumber; /*Employee ID number*/
  15. float overtimePay;//overtime wage rate
  16. float overtimeHours;//overtime hours worked
  17. float normalPay;//normal weekly pay without overtime
  18. float gross;/*Gross pay for each employee*/
  19. float hours;/*Number of hours worked*/
  20. float wageRate;/*Employee hourly wage*/
  21. float otGross; //overtime pay per week
  22.  
  23. printf("\n\t*** Pay Calculator ***\n");
  24.  
  25. for (idx=1;idx<=employeesWorked; ++idx)
  26. {
  27. printf("\n\tEnter clock number for employee:");
  28. scanf ("%d", &clockNumber);
  29. printf ("\n\tEnter hourly wage for employee:");
  30. scanf ("%f", &wageRate);
  31. printf ("\n\tEnter the number of hours the employee worked:");
  32. scanf ("%f", &hours);
  33.  
  34. if (hours > standardHours) {
  35. overtimeHours = hours - standardHours;//calculate overtime hours
  36. overtimePay = wageRate*1.5;//calculate overtime wage
  37. otGross = overtimePay*overtimeHours;//calculate gross pay from overtime hours
  38. normalPay = standardHours * wageRate;//gross pay before overtime
  39. gross = normalPay + otGross;//gross pay including overtime
  40.  
  41.  
  42. }//end if
  43. else {
  44. normalPay = hours*wageRate;//calculate normal pay with no overtime
  45. otGross = 0;
  46. overtimeHours = 0.0;
  47. }//end else
  48.  
  49. gross = normalPay + otGross; /*calculate gross pay*/
  50.  
  51. printf("\n\n\t----------------------------------------------------------\n");
  52. printf("\tClock # Wage Hours OT Gross\n");
  53. printf("\t----------------------------------------------------------\n");
  54.  
  55. printf("\t%06i %5.2f %5.1f %5.1f %7.2f\n", clockNumber, wageRate, hours, overtimeHours, gross);
  56.  
  57. }//for
  58. return(0);
  59. }//main
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 for employee:
	Enter hourly wage for employee:
	Enter the number of hours the employee worked:

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

	Enter clock number for employee:
	Enter hourly wage for employee:
	Enter the number of hours the employee worked:

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

	Enter clock number for employee:
	Enter hourly wage for employee:
	Enter the number of hours the employee worked:

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

	Enter clock number for employee:
	Enter hourly wage for employee:
	Enter the number of hours the employee worked:

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

	Enter clock number for employee:
	Enter hourly wage for employee:
	Enter the number of hours the employee worked:

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