fork(1) download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Paul Santos
  6. //
  7. // Class: C Programming, Spring 2023
  8. //
  9. // Date: 1/24/23
  10. //
  11. // Description: Program which determines gross pay and outputs
  12. // be sent to a designated file. This version does not use file pointers
  13. //
  14. //
  15. //********************************************************
  16.  
  17. #include <stdio.h>
  18. int main()
  19. {
  20. int employees_num; /* number of employees */
  21. int clock_num; /* employee clock number */
  22. float gross; /* gross pay for week (wage * hours) */
  23. float hours; /* number of hours worked per week */
  24. float wage; /* hourly wage */
  25. int i; /* counter */
  26.  
  27. /* Prompt for input values from the screen */
  28.  
  29. printf ("This is a program to calculate gross pay.\n");
  30. printf ("You will be prompted for data for five employees.\n\n");
  31. printf (" *** This is a pay calculator. *** \n");
  32.  
  33. for (i = 1; i <= 5; i++)
  34. {
  35.  
  36. printf("Enter number of employees: ");
  37. scanf ("%d", &employees_num);
  38. printf ("Enter clock number: ");
  39. scanf ("%d", &clock_num);
  40. printf ("Enter weekly wage for employee: ");
  41. scanf ("%f", &wage);
  42. printf ("Enter the number of hours the employee worked: ");
  43. scanf ("%f", &hours);
  44.  
  45. /* calculate gross pay */
  46. gross = wage * hours;
  47.  
  48. /* print out employee information */
  49. printf ("\n\t\tPaul Santos, C Programming, First Homework Assignment\n\n\n");
  50. printf ("\t----------------------------------------------------------\n");
  51. printf ("\tClock # Wage Hours Gross\n");
  52. printf ("\t----------------------------------------------------------\n");
  53.  
  54. printf ("\t%06i %5.2f %5.1f %7.2f\n",clock_num, wage, hours, gross);
  55. }
  56. return (0); /* success */
  57.  
  58. } /* main */
  59.  
Success #stdin #stdout 0s 5436KB
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
This is a program to calculate gross pay.
You will be prompted for data for five employees.

 *** This is a pay calculator. *** 
Enter number of employees: Enter clock number: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Paul Santos, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	098401 10.60  51.0  540.60
Enter number of employees: Enter clock number: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Paul Santos, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	000009  0.75  42.5   31.88
Enter number of employees: Enter clock number: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Paul Santos, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	000010  0.50  37.0   18.50
Enter number of employees: Enter clock number: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Paul Santos, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	000012  0.25  45.0   11.25
Enter number of employees: Enter clock number: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Paul Santos, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	000008  0.35   0.0    0.00