fork download
  1. //*******************************************************
  2. //
  3. // Assignment 3 - Conditionals
  4. //
  5. // Name: Andrea Huskey
  6. //
  7. // Class: C Programming, Summer 2026
  8. //
  9. // Date: June 12, 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. #define STD_HOURS 40.0 // 40 hour work week constant
  20. #define NUM_EMPLOYEES 5 // Number of employees 5 constant
  21. #define OVER_TIMERATE 1.5 // 1.5 overtime constant
  22. #define M_S "Tim N." // Reviewed by Management
  23.  
  24. int main()
  25. {
  26.  
  27. int clockNumber; // Employee clock number
  28. float grossPay; // The weekly gross pay which is the normalPay + any overtimePay
  29. float hours; // Total hours worked in a week
  30. float normalPay; // Standard weekly normal pay without overtime
  31. float overtimeHrs; // Any hours worked past the normal scheduled work week
  32. float overtimePay; // Additional overtime pay for any overtime hours worked
  33. float wageRate; // Hourly wage for an employee
  34.  
  35. printf ("\n*** Pay Calculator ***");
  36.  
  37. for (int i = 0; i < NUM_EMPLOYEES; i++) { // Process each employee
  38.  
  39. printf("\n\nEnter clock number: "); // Prompt the user for the clock number
  40. scanf("%d", &clockNumber);
  41.  
  42. printf("\nEnter wage rate: "); // Prompt the user for the wage rate
  43. scanf("%f", &wageRate);
  44.  
  45. printf("\nEnter number of hours worked: "); // Prompt the user for the number of hours worked
  46. scanf("%f", &hours);
  47.  
  48. if (hours > STD_HOURS) { // Calculate the overtime hours, normal pay, and overtime pay
  49. overtimeHrs = hours - STD_HOURS; // Use completed hours minus constant - leaving only OT hours
  50. overtimePay = ((wageRate * OVER_TIMERATE) * overtimeHrs); // Use hourly rate * 1.5 constant then multiply only OT hours
  51. normalPay = (hours - overtimeHrs) * wageRate; // Use subtract ot hours from regular hours and multiply hourly rate - took me forever to figure out.
  52. grossPay = normalPay + overtimePay; // Multiply normal pay with Overtime pay for total my numbers were off thus the extra columns
  53.  
  54. } else {
  55. overtimeHrs = 0; // else statement - zero out unnecessary hours
  56. overtimePay = 0; // else statement - zero out unnecessary hours
  57. normalPay = hours * wageRate; // restate hours to wage rate
  58. grossPay = normalPay; // restate hours to wage rate
  59. } // close if block
  60.  
  61. printf("\n\nClock# Wage Hours OTHRS OTPAY NormalPay Gross\n"); // Print header information on the current employee
  62. printf("---------------------------------------------------------------\n");
  63. printf("%06d %5.2f %5.1f %5.1f %5.2f %5.2f %8.2f\n", // spacing and listing for print columns
  64. clockNumber, wageRate, hours, overtimeHrs, overtimePay, normalPay, grossPay);
  65. } // close print block
  66.  
  67. return 0;
  68. } //end code
Success #stdin #stdout 0s 5324KB
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  OTHRS  OTPAY  NormalPay  Gross
---------------------------------------------------------------
098401 10.60  51.0  11.0   174.90  424.00   598.90


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OTHRS  OTPAY  NormalPay  Gross
---------------------------------------------------------------
526488  9.75  42.5   2.5   36.56  390.00   426.56


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OTHRS  OTPAY  NormalPay  Gross
---------------------------------------------------------------
765349 10.50  37.0   0.0    0.00  388.50   388.50


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OTHRS  OTPAY  NormalPay  Gross
---------------------------------------------------------------
034645 12.25  45.0   5.0   91.88  490.00   581.88


Enter clock number: 
Enter wage rate: 
Enter number of hours worked: 

Clock# Wage  Hours  OTHRS  OTPAY  NormalPay  Gross
---------------------------------------------------------------
127615  8.35   0.0   0.0    0.00   0.00     0.00