fork(1) download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Miguel Baez
  6. //
  7. // Class: C Programming, Spring 2025
  8. //
  9. // Date: 02/09/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. int clockNumber; // employee clock number
  23. float gross; // gross pay for week (wage * hours)
  24. float hours; // number of hours worked per week
  25. float wageRate; // hourly wage
  26.  
  27. int empNum;
  28.  
  29. int i;
  30.  
  31. printf ("\n\t*** Pay Calculator ***\n");
  32.  
  33.  
  34.  
  35. // Prompt for input values from the screen
  36. printf ("\n\tEnter clock number for employee: 98401");
  37. scanf ("%d", &clockNumber);
  38. printf ("\n\tEnter hourly wage for employee: 10.60 ");
  39. scanf ("%f", &wageRate);
  40. printf ("\n\tEnter the number of hours the employee worked: 51.0 ");
  41. scanf ("%f", &hours);
  42.  
  43. // calculate gross pay
  44. gross = wageRate * hours;
  45.  
  46. // print out employee information
  47. printf ("\n\n\t----------------------------------------------------------\n");
  48. printf ("\tClock # Wage Hours Gross\n");
  49. printf ("\t----------------------------------------------------------\n");
  50.  
  51. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, gross);
  52.  
  53. return (0); // success
  54.  
  55. } // main
Success #stdin #stdout 0s 5284KB
stdin
98401
10.60
51.0
stdout
	*** Pay Calculator ***

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

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	098401 10.60  51.0  540.60