fork download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Anthony Principe
  6. //
  7. // Class: C Programming, Fall 2025
  8. //
  9. // Date: September 12, 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. #include <stdio.h>
  19. int main ()
  20. {
  21.  
  22. // declare variables and how they are used */
  23. int clockNumber; /* employee clock number */
  24. float gross; /* gross pay for week (wage * hours) */
  25. float hours; /* number of hours worked per week */
  26. float wageRate; /* hourly wage */
  27.  
  28. printf ("\n\t*** Pay Calculator ***\n");
  29.  
  30. /* Prompt for input values from the screen */
  31. printf ("\n\tEnter clock number for employee: ");
  32. scanf ("%d", &clockNumber);
  33. printf ("\n\tEnter hourly wage for employee: ");
  34. scanf ("%f", &wageRate);
  35. printf ("\n\tEnter the number of hours the employee worked: ");
  36. scanf ("%f", &hours);
  37.  
  38. /* calculate gross pay */
  39. gross = wageRate * hours;
  40.  
  41. /* print out employee information */
  42. printf ("\n\n\t----------------------------------------------------------\n");
  43. printf ("\tClock # Wage Hours Gross\n");
  44. printf ("\t----------------------------------------------------------\n");
  45.  
  46. /* print the data for the current employee */
  47. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, gross);
  48.  
  49. return (0); // success
  50.  
  51. } // end main
Success #stdin #stdout 0.01s 5284KB
stdin
98401 10.60 51.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