fork download
  1. //*******************************************************
  2. //
  3. // Homework: 2
  4. //
  5. // Name: Matt Smith
  6. //
  7. // Class: C Programming, Spring 2025
  8. //
  9. // Date: 2/5/2025
  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.  
  19. int main(void) {
  20. int clockNumber; //employee clock number
  21. float grossPay; //gross pay for week (wage * hours)
  22. float hours; //number of hours worked per week
  23. float wageRate; //hourly wage
  24. //TODO - Add two variables, one for a loop index, and another for a loop test
  25. int idx; //loop index variable
  26. int empNum; //number of employees
  27.  
  28. printf ("*** Pay Calculator ***\n");
  29.  
  30. //TODO - Add your prompt to determine how many employees to process
  31.  
  32. printf ("\nEnter number of employees to process: ");
  33. scanf ("%i", &empNum);
  34.  
  35. //TODO - Add a loop of your choice here (for, do or while) to process each employee
  36. for ( idx = 0; idx <= empNum; ++idx ) {
  37. //Prompt for input values from the screen
  38. printf ("\nEnter clock number for employee: ");
  39. scanf ("%d", &clockNumber);
  40. printf ("\nEnter hourly wage for employee: ");
  41. scanf ("%f", &wageRate);
  42. printf ("\nEnter the number of hours the employee worked: ");
  43. scanf ("%f", &hours);
  44.  
  45. //Calculate gross pay
  46. grossPay = wageRate * hours;
  47.  
  48. //print out employee information
  49. printf ("\n\n\t-----------------------------------------------------------------\n");
  50. printf ("\tClock # Wage Hours Gross\n");
  51. printf ("\t-----------------------------------------------------------------\n");
  52.  
  53. //print the data for the current employee
  54. printf ("\t%06i %5.2f %5.1f %7.2f\n", clockNumber, wageRate, hours, grossPay);
  55.  
  56. //TODO - end your loop here
  57.  
  58. }
  59.  
  60. return 0;
  61. }
Success #stdin #stdout 0.01s 5276KB
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 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

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