fork download
  1. //*******************************************************
  2. //
  3. // Homework: 2
  4. //
  5. // Name: Sovanna Mann
  6. //
  7. // Class: C Programming, Fall 2024
  8. //
  9. // Date: 9/18/2024
  10. //
  11. // Description: Program which determines gross pay
  12. // and outputs are sent to standard output (the screen).
  13. //
  14. //
  15. //********************************************************
  16.  
  17. #include <stdio.h>
  18. int main ( )
  19. {
  20.  
  21. int clockNumber; // employee clock number
  22. float grossPay; // gross pay for week (wage * hours)
  23. float hours; // number of hours worked per week
  24. float wageRate; // hourly wage
  25.  
  26. // TODO - Add two variables, one for a loop index, another for a loop test
  27. int i; /* loop index */
  28. int n; /* loop test */
  29.  
  30. printf ("*** Pay Calculator ***\n");
  31.  
  32.  
  33. // TODO - Add your prompt to capture how many employees to process
  34. /* prompt for max employee value */
  35. printf("Enter number of employee: ");
  36. scanf ("%i", &n);
  37.  
  38. // TODO - Add a loop of your choice here (for, while, or do) to process each employee
  39. /* loop from 1 to n */
  40. for (i=1; i <= n; ++i)
  41. {
  42.  
  43. // Prompt for input values from the screen
  44. printf ("\nEnter clock number for employee: ");
  45. scanf ("%d", &clockNumber);
  46. printf ("\nEnter hourly wage for employee: ");
  47. scanf ("%f", &wageRate);
  48. printf ("\nEnter the number of hours the employee worked: ");
  49. scanf ("%f", &hours);
  50.  
  51. // calculate gross pay
  52. grossPay = wageRate * hours;
  53.  
  54. // print out employee information
  55. printf ("\n\n\t----------------------------------------------------------\n");
  56. printf ("\tClock # Wage Hours Gross\n");
  57. printf ("\t----------------------------------------------------------\n");
  58.  
  59. // print the data for the current employee
  60. printf ("\t%06i %5.2f %5.1f %7.2f\n",clockNumber, wageRate, hours, grossPay);
  61.  
  62. } // TODO - end your loop here
  63.  
  64. return (0); // success
  65.  
  66. } // main
Success #stdin #stdout 0.01s 5280KB
stdin
5
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 number of employee: 
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

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

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	526488  9.75  42.5  414.38

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

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	765349 10.50  37.0  388.50

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

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	034645 12.25  45.0  551.25

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

	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	127615  8.35   0.0    0.00