fork download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Timothy Niesen
  6. //
  7. // Class: C Programming, Spring 2023
  8. //
  9. // Date: 1/26/23
  10. //
  11. // Description: Program which determines gross pay and outputs
  12. // to the screen. This version does not use file pointers
  13. //
  14. //
  15. //********************************************************
  16.  
  17. #include <stdio.h>
  18. int main()
  19. {
  20.  
  21. int clock_num; /* employee clock number */
  22. float gross; /* gross pay for week (wage * hours) */
  23. float hours; /* number of hours worked per week */
  24. float wage; /* hourly wage */
  25. int numOfEmployees;
  26.  
  27. printf ("\n\t*** Pay Calculator ***\n");
  28.  
  29. printf ("Enter number of employees: ");
  30. scanf ("%i", &numOfEmployees);
  31.  
  32. for (int i = 0; numOfEmployees > i; ++i )
  33. {
  34. /* Prompt for input values from the screen for each employee */
  35. printf ("\n\tEnter clock number for employee: ");
  36. scanf ("%d", &clock_num);
  37. printf ("\n\tEnter hourly wage for employee: ");
  38. scanf ("%f", &wage);
  39. printf ("\n\tEnter the number of hours the employee worked: ");
  40. scanf ("%f\n", &hours);
  41.  
  42. /* calculate gross pay */
  43. gross = wage * hours;
  44.  
  45. /* print out employee information */
  46. printf ("\n\n\t----------------------------------------------------------\n");
  47. printf ("\tClock # Wage Hours Gross\n");
  48. printf ("\t----------------------------------------------------------\n");
  49.  
  50. printf ("\t%06i %5.2f %5.1f %7.2f\n",clock_num, wage, hours, gross);
  51. }
  52.  
  53. return (0); /* success */
  54.  
  55. } /* main */
  56.  
Success #stdin #stdout 0s 5436KB
stdin
2
23456
23.45
46.1
68411
35.5
72
stdout
	*** Pay Calculator ***
Enter number of employees: 
	Enter clock number for employee: 
	Enter hourly wage for employee: 
	Enter the number of hours the employee worked: 

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	023456 23.45  46.1 1081.05

	Enter clock number for employee: 
	Enter hourly wage for employee: 
	Enter the number of hours the employee worked: 

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	068411 35.50  72.0 2556.00