fork download
  1. //*******************************************************
  2. //
  3. // Homework: Assignment 3 - Conditionals
  4. //
  5. // Name: Jessica Theman
  6. //
  7. // Class: C Programming, Fall 2025
  8. //
  9. // Date: September 24, 2025
  10. //
  11. // Description: Program which determines overtime and gross
  12. // pay for a set of employees with outputs sent to standard
  13. // output (the screen).
  14. //
  15. // Non file pointer solution
  16. //
  17. //********************************************************
  18.  
  19. #include <stdio.h>
  20.  
  21. // Declare constants
  22. #define STD_HOURS 40.0 //Standard hours
  23. #define NUM_EMPLOYEES 5 //Number of employees
  24. #define OVRTM_PAY 1.5 //Overtime pay rate to multiply standard wage by
  25.  
  26. int main( )
  27. {
  28. int clockNumber; //Employee clock number
  29. float grossPay; //The weekly gross pay which is normalPay + any overtimePay
  30. float hours; //Total hours worked in a week
  31. float normalPay; //Standard weekly normal pay without overtime
  32. float overtimeHrs; //Any hours worked past the normal scheduled work week
  33. float overtimePay; //Additional overtime pay for any overtime hours worked
  34. float wageRate; //Hourly wage for an employee
  35.  
  36. printf("\t*** Pay Calculator ***\n\n");
  37.  
  38. //Process each employee
  39. for (int i=0; i<NUM_EMPLOYEES; i++)
  40.  
  41. {
  42. // Prompt the user for the clock number
  43. printf("\tEnter clock number: \n");
  44. scanf("%d", &clockNumber);
  45.  
  46. // Prompt the user for the wage rate
  47. printf("\tEnter wage rate: \n");
  48. scanf("%f", &wageRate);
  49.  
  50. // Prompt the user for the number of hours worked
  51. printf("\tEnter number of hours worked: \n");
  52. scanf("%f", &hours);
  53.  
  54. // Calculate the overtime hours, normal pay, and overtime pay
  55. if(hours>STD_HOURS)
  56. {
  57. overtimeHrs = hours - STD_HOURS;
  58. normalPay = wageRate * STD_HOURS;
  59. overtimePay = overtimeHrs * (OVRTM_PAY * wageRate);
  60. }
  61. else
  62. {
  63. overtimeHrs = 0;
  64. normalPay = hours * wageRate;
  65. overtimePay = 0;
  66. }
  67.  
  68. // Calculate the gross pay with normal pay and any additional overtime pay
  69. grossPay = normalPay + overtimePay;
  70.  
  71. // Print out information on the current employee
  72. printf ("\t----------------------------------------------------------\n");
  73. printf ("\tClock# Wage Hours OT RegPay OTPay Gross\n");
  74. printf ("\t----------------------------------------------------------\n");
  75. printf("\t%06i %-5.2f %-6.1f %-5.1f %-8.2f %-7.2f %-7.2f\n\n", clockNumber, wageRate, hours, overtimeHrs, normalPay, overtimePay, grossPay);
  76. }//for
  77.  
  78. return 0;
  79. }//nain
  80.  
Success #stdin #stdout 0.01s 5292KB
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     RegPay    OTPay    Gross
	----------------------------------------------------------
	098401   10.60   51.0    11.0   424.00    174.90   598.90 

	Enter clock number: 
	Enter wage rate: 
	Enter number of hours worked: 
	----------------------------------------------------------
	Clock#   Wage    Hours   OT     RegPay    OTPay    Gross
	----------------------------------------------------------
	526488   9.75    42.5    2.5    390.00    36.56    426.56 

	Enter clock number: 
	Enter wage rate: 
	Enter number of hours worked: 
	----------------------------------------------------------
	Clock#   Wage    Hours   OT     RegPay    OTPay    Gross
	----------------------------------------------------------
	765349   10.50   37.0    0.0    388.50    0.00     388.50 

	Enter clock number: 
	Enter wage rate: 
	Enter number of hours worked: 
	----------------------------------------------------------
	Clock#   Wage    Hours   OT     RegPay    OTPay    Gross
	----------------------------------------------------------
	034645   12.25   45.0    5.0    490.00    91.88    581.88 

	Enter clock number: 
	Enter wage rate: 
	Enter number of hours worked: 
	----------------------------------------------------------
	Clock#   Wage    Hours   OT     RegPay    OTPay    Gross
	----------------------------------------------------------
	127615   8.35    0.0     0.0    0.00      0.00     0.00