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

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	000005 98401.00  10.6 1043050.62