fork download
  1. //*******************************************************
  2. //
  3. // Homework: 2
  4. //
  5. // Name: Joe Student
  6. //
  7. // Class: C Programming, Summer 2026
  8. //
  9. // Date: June 1, 2026
  10. //
  11. // Description: Program which determines gross pay and outputs
  12. // to the screen using a loop. This version does not use file
  13. // pointers
  14. //
  15. // Non file pointer solution
  16. //
  17. //********************************************************
  18.  
  19. #include <stdio.h>
  20. int main ()
  21. {
  22.  
  23. int clockNumber; // employee clock number
  24. float gross; // gross pay for week (wage * hours)
  25. float hours; // number of hours worked per week
  26. float wageRate; // hourly wage
  27.  
  28. int i; // loop index
  29. int empNum; // number of employees to process
  30.  
  31. // prompt for number of employees to process
  32. printf ("Enter number of employee: ");
  33. scanf ("%i", &empNum);
  34.  
  35. printf ("\n\t*** Pay Calculator ***\n");
  36.  
  37. // process each employee
  38. for (i = 0; i <= empNum; ++i)
  39. {
  40. // Prompt for input values from the screen
  41. printf ("\n\tEnter clock number for employee: ");
  42. scanf ("%d", &clockNumber);
  43. printf ("\n\tEnter hourly wage for employee: ");
  44. scanf ("%f", &wageRate);
  45. printf ("\n\tEnter the number of hours the employee worked: ");
  46. scanf ("%f", &hours);
  47.  
  48. // calculate gross pay
  49. gross = wageRate * hours;
  50.  
  51. // print out employee information
  52. printf ("\n\n\t----------------------------------------------------------\n");
  53. printf ("\tClock # Wage Hours Gross\n");
  54. printf ("\t----------------------------------------------------------\n");
  55.  
  56. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, gross);
  57.  
  58. } // for
  59.  
  60. return (0); // success
  61.  
  62. } // main
  63.  
  64.  
Success #stdin #stdout 0s 5312KB
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
Enter number of employee: 
	*** Pay Calculator ***

	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

	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