fork download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Joshua Lane
  6. //
  7. // Class: C Programming, Fall 2026
  8. //
  9. // Date: September 10th, 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. // Establishes the variables to be used throughout the program
  23.  
  24. int clockNumber; // employee clock number
  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. // Prints a page header of sorts to show the user what this tool is
  30.  
  31. printf ("\n\t***Pay Calculator***\n");
  32.  
  33. // In a non-ideone setting, these scanf functions would prompt the user
  34. // to input the corresponding values of the employee in question
  35. // Also dictates the type of values that are able to be input by the user
  36.  
  37. // Unclear if it was intentional or not, but the actual text strings themselves
  38. // vary between the template and the sample output provided. Corrected to match sample.
  39.  
  40. // Prompt for input values from the screen
  41. printf ("\n\tEnter Employee's Clock #: ");
  42. scanf ("%d", &clockNumber);
  43. printf ("\n\tEnter hourly wage: ");
  44. scanf ("%f", &wageRate);
  45. printf ("\n\tEnter number of hours worked: ");
  46. scanf ("%f", &hours);
  47.  
  48. // Uses input values (assigned to variables) to calculate
  49. // the wages of the specified employee
  50.  
  51. // calculate gross pay
  52. gross = wageRate * hours;
  53.  
  54. // Prints out an additional header to make the stdout readable
  55.  
  56. // print out employee information
  57. printf ("\n\n\t-----------------------------------------\n");
  58. printf ("\tClock# Wage Hours Gross\n");
  59. printf ("\t-----------------------------------------\n");
  60.  
  61. // Prints the final results of the tool
  62. // Formats the data types as required for money vs non-money values
  63.  
  64. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, gross);
  65.  
  66. return (0); // success
  67.  
  68. } // main
Success #stdin #stdout 0s 5304KB
stdin
98401
10.60
51.0
stdout
	***Pay Calculator***

	Enter Employee's Clock #: 
	Enter hourly wage: 
	Enter number of hours worked: 

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