fork download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: <Will Vanier>
  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. #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. printf ("\n\t*** Pay Calculator ***\n");
  28.  
  29. // Prompt for input values from the screen
  30. printf ("\n\tEnter clock number for employee: 98401");
  31. scanf ("%d", &clockNumber);
  32. printf ("\n\tEnter hourly wage for employee: 10.60 ");
  33. scanf ("%f", &wageRate);
  34. printf ("\n\tEnter the number of hours the employee worked: 51.0 ");
  35. scanf ("%f", &hours);
  36.  
  37. // calculate gross pay
  38. gross = wageRate * hours;
  39.  
  40. // print out employee information
  41. printf ("\n\n\t----------------------------------------------------------\n");
  42. printf ("\tClock # Wage Hours Gross\n");
  43. printf ("\t----------------------------------------------------------\n");
  44.  
  45. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, gross);
  46.  
  47. return (0); // success
  48.  
  49. int clockNumberTwo; // employee clock number
  50. float grossTwo; // gross pay for week (wage * hours)
  51. float hoursTwo; // number of hours worked per week
  52. float wageRateTwo; // hourly wage
  53.  
  54. printf ("\n\t*** Pay Calculator ***\n");
  55.  
  56. // Prompt for input values from the screen
  57. printf ("\n\tEnter clock number for employee: 526488");
  58. scanf ("%d", &clockNumberTwo);
  59. printf ("\n\tEnter hourly wage for employee: 9.75 ");
  60. scanf ("%f", &wageRateTwo);
  61. printf ("\n\tEnter the number of hours the employee worked: 42.5 ");
  62. scanf ("%f", &hoursTwo);
  63.  
  64. // calculate gross pay
  65. grossTwo = wageRateTwo * hoursTwo;
  66.  
  67. // print out employee information
  68. printf ("\n\n\t----------------------------------------------------------\n");
  69. printf ("\tClock # Wage Hours Gross\n");
  70. printf ("\t----------------------------------------------------------\n");
  71.  
  72. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumberTwo, wageRateTwo, hoursTwo, grossTwo);
  73.  
  74. return (0); // success
  75. int clockNumberThree; // employee clock number
  76. float grossThree; // gross pay for week (wage * hours)
  77. float hoursThree; // number of hours worked per week
  78. float wageRateThree; // hourly wage
  79.  
  80. printf ("\n\t*** Pay Calculator ***\n");
  81.  
  82. // Prompt for input values from the screen
  83. printf ("\n\tEnter clock number for employee: 765349");
  84. scanf ("%d", &clockNumberThree);
  85. printf ("\n\tEnter hourly wage for employee: 10.50 ");
  86. scanf ("%f", &wageRateThree);
  87. printf ("\n\tEnter the number of hours the employee worked: 37.0 ");
  88. scanf ("%f", &hoursThree);
  89.  
  90. // calculate gross pay
  91. grossThree = wageRateThree * hoursThree;
  92.  
  93. // print out employee information
  94. printf ("\n\n\t----------------------------------------------------------\n");
  95. printf ("\tClock # Wage Hours Gross\n");
  96. printf ("\t----------------------------------------------------------\n");
  97.  
  98. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumberThree, wageRateThree, hoursThree, grossThree);
  99.  
  100. return (0); // success
  101. int clockNumberFour; // employee clock number
  102. float grossFour; // gross pay for week (wage * hours)
  103. float hoursFour; // number of hours worked per week
  104. float wageRateFour; // hourly wage
  105.  
  106. printf ("\n\t*** Pay Calculator ***\n");
  107.  
  108. // Prompt for input values from the screen
  109. printf ("\n\tEnter clock number for employee: 34645");
  110. scanf ("%d", &clockNumberFour);
  111. printf ("\n\tEnter hourly wage for employee: 12.25 ");
  112. scanf ("%f", &wageRateFour);
  113. printf ("\n\tEnter the number of hours the employee worked: 45.0 ");
  114. scanf ("%f", &hoursFour);
  115.  
  116. // calculate gross pay
  117. grossFour = wageRateFour * hoursFour;
  118.  
  119. // print out employee information
  120. printf ("\n\n\t----------------------------------------------------------\n");
  121. printf ("\tClock # Wage Hours Gross\n");
  122. printf ("\t----------------------------------------------------------\n");
  123.  
  124. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumberFour, wageRateFour, hoursFour, grossFour);
  125.  
  126. return (0); // success
  127. int clockNumberFive; // employee clock number
  128. float grossFive; // gross pay for week (wage * hours)
  129. float hoursFive; // number of hours worked per week
  130. float wageRateFive; // hourly wage
  131.  
  132. printf ("\n\t*** Pay Calculator ***\n");
  133.  
  134. // Prompt for input values from the screen
  135. printf ("\n\tEnter clock number for employee: 127615");
  136. scanf ("%d", &clockNumberFive);
  137. printf ("\n\tEnter hourly wage for employee: 8.35 ");
  138. scanf ("%f", &wageRateFive);
  139. printf ("\n\tEnter the number of hours the employee worked: 0.0 ");
  140. scanf ("%f", &hoursFive);
  141.  
  142. // calculate gross pay
  143. grossFive = wageRateFive * hoursFive;
  144.  
  145. // print out employee information
  146. printf ("\n\n\t----------------------------------------------------------\n");
  147. printf ("\tClock # Wage Hours Gross\n");
  148. printf ("\t----------------------------------------------------------\n");
  149.  
  150. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumberFive, wageRateFive, hoursFive, grossFive);
  151.  
  152. return (0); // success
  153. } // main
Success #stdin #stdout 0s 5316KB
stdin
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: 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