fork download
  1. //*******************************************************
  2. //
  3. // Homework: 2
  4. //
  5. // Name: Steve Haguma
  6. //
  7. // Class: C Programming, 2025
  8. //
  9. // Date: September 22, 2025
  10. //
  11. // Description: Program which determines gross pay for multiple employees
  12. // using loops and outputs are sent to standard output (the screen).
  13. //
  14. //********************************************************
  15.  
  16. #include <stdio.h>
  17.  
  18. int main()
  19. {
  20. int clockNumber; // employee clock number
  21. float grossPay; // gross pay for week (wage * hours)
  22. float hours; // number of hours worked per week
  23. float wageRate; // hourly wage
  24. int empNum; // number of employees to process
  25. int i; // loop counter
  26.  
  27. printf("*** Pay Calculator ***\n");
  28.  
  29. // Prompt for number of employees to process
  30. printf("Enter number of employees to process: ");
  31. scanf("%d", &empNum);
  32.  
  33. // Loop to process each employee
  34. for (i = 1; i <= empNum; ++i)
  35. {
  36. // Prompt for input values from the screen
  37. printf("\nEnter clock number for employee: ");
  38. scanf("%d", &clockNumber);
  39.  
  40. printf("Enter hourly wage for employee: ");
  41. scanf("%f", &wageRate);
  42.  
  43. printf("Enter the number of hours the employee worked: ");
  44. scanf("%f", &hours);
  45.  
  46. // Calculate gross pay
  47. grossPay = wageRate * hours;
  48.  
  49. // Print out employee information
  50. printf("\n-----------------------------------------\n");
  51. printf("Clock# Wage Hours Gross\n");
  52. printf("-----------------------------------------\n");
  53.  
  54. // Print the data for the current employee
  55. printf("%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, grossPay);
  56. }
  57.  
  58. return (0); // success
  59. }
Success #stdin #stdout 0.01s 5292KB
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 number of employees to process: 
Enter clock number for employee: Enter hourly wage for employee: Enter the number of hours the employee worked: 
-----------------------------------------
Clock# Wage Hours Gross
-----------------------------------------
098401 10.60  51.0  540.60

Enter clock number for employee: Enter hourly wage for employee: Enter the number of hours the employee worked: 
-----------------------------------------
Clock# Wage Hours Gross
-----------------------------------------
526488  9.75  42.5  414.38

Enter clock number for employee: Enter hourly wage for employee: Enter the number of hours the employee worked: 
-----------------------------------------
Clock# Wage Hours Gross
-----------------------------------------
765349 10.50  37.0  388.50

Enter clock number for employee: Enter hourly wage for employee: Enter the number of hours the employee worked: 
-----------------------------------------
Clock# Wage Hours Gross
-----------------------------------------
034645 12.25  45.0  551.25

Enter clock number for employee: Enter hourly wage for employee: Enter the number of hours the employee worked: 
-----------------------------------------
Clock# Wage Hours Gross
-----------------------------------------
127615  8.35   0.0    0.00