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