fork 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; // employee number
  24. int i; // loop index
  25.  
  26. empNum = 5;
  27.  
  28. printf ("*** Pay Calculator ***\n");
  29.  
  30.  
  31. for(i = 1; i <= empNum; i++) // For loop since that felt easiest
  32.  
  33. {
  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. // calculate gross pay
  43. grossPay = wageRate * hours;
  44. // print out employee information
  45. printf ("\n\n\t----------------------------------------------------------\n");
  46. printf ("\tClock # Wage Hours Gross\n");
  47. printf ("\t----------------------------------------------------------\n");
  48. // print the data for the current employee
  49. printf ("\t%06i %5.2f %5.1f %7.2f\n",clockNumber, wageRate, hours, grossPay);
  50.  
  51. }// It took me a really long time to remember this was needed to end the loop
  52.  
  53. return (0); // success
  54. } // main
Success #stdin #stdout 0.01s 5324KB
stdin
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 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