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