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

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

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

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

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

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

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

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

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

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