fork download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: <Felix Henriquez>
  6. //
  7. // Class: C Programming, <Fall 2025>
  8. //
  9. // Date: <September 14, 2025>
  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.  
  19. #include <stdio.h>
  20. int main ()
  21. {
  22. // Initialize variables with test data directly
  23. int clockNumber = 197620; // employee clock number
  24. float wageRate = 22.75; // hourly wage
  25. float hours = 35.5; // number of hours worked per week
  26. float gross; // gross pay for week (wage * hours)
  27.  
  28. printf ("\n\t*** Pay Calculator ***\n");
  29.  
  30. // No need for scanf prompts, values are already set.
  31. // printf ("\n\tEnter clock number for employee: ");
  32. // scanf ("%d", &clockNumber);
  33. // ... etc ...
  34.  
  35. // calculate gross pay
  36. gross = wageRate * hours;
  37.  
  38. // print out employee information
  39. printf ("\n\n\t----------------------------------------------------------\n");
  40. printf ("\tClock # Wage Hours Gross\n");
  41. printf ("\t----------------------------------------------------------\n");
  42.  
  43. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, gross);
  44.  
  45. return (0); // success
  46.  
  47. } // main
Success #stdin #stdout 0.01s 5292KB
stdin
23456
23.45
46.1
stdout
	*** Pay Calculator ***


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	197620 22.75  35.5  807.62