fork(1) download
  1. //*******************************************************
  2. //
  3. // Homework: 2
  4. //
  5. // Name: John Eneh
  6. //
  7. // Class: C Programming, Fall 2025
  8. //
  9. // Date: 9/20/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. int empNum;
  24. int i;
  25.  
  26. printf ("*** Pay Calculator ***\n");
  27.  
  28. printf ("\nEnter number of employees to process: "); // Prompt to capture how many employees to process
  29. scanf ("%d", &empNum);
  30.  
  31. for(i = 1; i <= empNum; i++) // For loop since that felt easiest
  32.  
  33. {
  34. // Prompt for input values from the screen
  35. printf ("\nEnter clock number for employee: ");
  36. scanf ("%d", &clockNumber);
  37. printf ("\nEnter hourly wage for employee: ");
  38. scanf ("%f", &wageRate);
  39. printf ("\nEnter the number of hours the employee worked: ");
  40. scanf ("%f", &hours);
  41. // calculate gross pay
  42. grossPay = wageRate * hours;
  43. // print out employee information
  44. printf ("\n\n\t----------------------------------------------------------\n");
  45. printf ("\tClock # Wage Hours Gross\n");
  46. printf ("\t----------------------------------------------------------\n");
  47. // print the data for the current employee
  48. printf ("\t%06i %5.2f %5.1f %7.2f\n",clockNumber, wageRate, hours, grossPay);
  49.  
  50. }// It took me a really long time to remember this was needed to end the loop
  51.  
  52. return (0); // success
  53. } // main
Success #stdin #stdout 0.01s 5276KB
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