fork download
  1. //*******************************************************
  2. //
  3. // Homework: 3
  4. //
  5. // Name: Sean Swanton
  6. //
  7. // Class: C Programming, Summer 2022
  8. //
  9. // Date: 6/11/22
  10. //
  11. // Description: a C program that will calculate the gross pay and
  12. // overtime hours for a set of employees using arrays.
  13. //
  14. //
  15. //********************************************************
  16.  
  17. #include <stdio.h>
  18. int main()
  19. {
  20.  
  21. int clock_num; /* employee clock number */
  22. float gross; /* gross pay for week (wage * hours) */
  23. float hours; /* number of hours worked per week */
  24. float wage; /* hourly wage */
  25. int employee_count; /* number of employees, used for the loop */
  26. int idx; /* loop index */
  27. const float STD_HOURS = 40.0;
  28. float OT;
  29. float otgross; /*used to help calculate overtime*/
  30. float thwage; /*wage at time and a half*/
  31. const int otcount;
  32. #define SIZE 5;
  33.  
  34. /* Prompt for input values from the screen */
  35. printf ("This is a program to calculate gross pay.\n");
  36. printf ("You will be prompted for employee data.\n\n");
  37. printf ("Enter number of employees you intend to calculate. \n");
  38. scanf ("%i", &employee_count);
  39. for ( idx = 1; idx <= employee_count; ++idx )
  40. {
  41. OT = 0.0;
  42. printf ("Enter clock number for employee: \n");
  43. scanf ("%d", &clock_num);
  44. printf ("Enter weekly wage for employee: \n");
  45. scanf ("%f", &wage);
  46. printf ("Enter the number of hours the employee worked: \n");
  47. scanf ("%f", &hours);
  48. if(hours > STD_HOURS)
  49. {
  50. OT = hours - STD_HOURS;
  51. /* calculate gross pay */
  52. gross = wage * STD_HOURS;
  53. thwage = wage + (wage / 2);
  54. otgross = thwage * OT;
  55. gross = gross + otgross;
  56. }
  57.  
  58. else
  59. {
  60. gross = wage * hours;
  61. }
  62.  
  63. /* print out employee information */
  64. printf ("\tClock # Wage Hours OT Gross\n");
  65. printf ("\t----------------------------------------------------------\n");
  66.  
  67. printf ("\t%06i %5.2f %5.1f %5.2f %3.0f\n",clock_num, wage, hours, OT, gross);
  68. }
  69.  
  70.  
  71. return (0); /* success */
  72.  
  73. } /* main */
  74.  
Success #stdin #stdout 0s 5280KB
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
This is a program to calculate gross pay.
You will be prompted for employee data.

Enter number of employees you intend to calculate. 
Enter clock number for employee: 
Enter weekly wage for employee: 
Enter the number of hours the employee worked: 
	Clock # Wage Hours OT Gross
	----------------------------------------------------------
	098401 10.60  51.0 11.00 599
Enter clock number for employee: 
Enter weekly wage for employee: 
Enter the number of hours the employee worked: 
	Clock # Wage Hours OT Gross
	----------------------------------------------------------
	526488  9.75  42.5  2.50 427
Enter clock number for employee: 
Enter weekly wage for employee: 
Enter the number of hours the employee worked: 
	Clock # Wage Hours OT Gross
	----------------------------------------------------------
	765349 10.50  37.0  0.00 388
Enter clock number for employee: 
Enter weekly wage for employee: 
Enter the number of hours the employee worked: 
	Clock # Wage Hours OT Gross
	----------------------------------------------------------
	034645 12.25  45.0  5.00 582
Enter clock number for employee: 
Enter weekly wage for employee: 
Enter the number of hours the employee worked: 
	Clock # Wage Hours OT Gross
	----------------------------------------------------------
	127615  8.35   0.0  0.00   0