fork(4) download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Corey Brucklerr
  6. //
  7. // Class: C Programming, Spring 2015
  8. //
  9. // Date: 02/03/15
  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. #define SIZE 5
  21. int clock_num = {98401, 526488, 765349, 34645, 127615}; /* employee clock number */
  22. float gross; /* gross pay for week (wage * hours) */
  23. float hours = {51.0, 42.5, 37.0, 45.0, 0}; /* number of hours worked per week */
  24. float wage = {10.6, 9.75, 10.5, 12.25, 8.35}; /* hourly wage */
  25. float calculate_gross; /* gross pay for week (wage * hours)*/
  26.  
  27. //Description of program's function
  28. printf ("This is a program to calculate gross pay.\n");
  29. printf ("You will be prompted for employee data.\n\n");
  30.  
  31. int counter;
  32.  
  33. //loops starts here
  34. for (counter = 1; counter <=5; ++counter)
  35.  
  36. {
  37.  
  38. printf ("Enter the number of hours the employee worked");
  39. scanf ("%f", &hours);
  40.  
  41.  
  42.  
  43.  
  44. /* Prompt for input values from the screen */
  45. printf ("This is a program to calculate gross pay.\n");
  46. printf ("You will be prompted for employee data.\n\n");
  47. printf ("Enter clock number for employee: ");
  48. scanf ("%d", &clock_num);
  49. printf ("Enter weekly wage for employee: ");
  50. scanf ("%f", &wage);
  51. printf ("Enter the number of hours the employee worked: ");
  52. scanf ("%f", &hours);
  53.  
  54. /* calculate gross pay */
  55. gross = wage * hours;
  56.  
  57. /* print out employee information */
  58. printf ("\n\t\tCorey, C Programming, First Homework Assignment\n\n\n");
  59. printf ("\t----------------------------------------------------------\n");
  60. printf ("\tClock # Wage Hours Gross\n");
  61. printf ("\t----------------------------------------------------------\n");
  62.  
  63. printf ("\t%06i %5.2f %5.1f %7.2f\n",clock_num, wage, hours, gross);
  64.  
  65. }
  66.  
  67. return (0); /* success */
  68.  
  69. } /* main */
  70.  
Success #stdin #stdout 0s 2056KB
stdin
Standard input is empty
stdout
This is a program to calculate gross pay.
You will be prompted for employee data.

Enter the number of hours the employee workedThis is a program to calculate gross pay.
You will be prompted for employee data.

Enter clock number for employee: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Corey, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	098401 10.60  51.0  540.60
Enter the number of hours the employee workedThis is a program to calculate gross pay.
You will be prompted for employee data.

Enter clock number for employee: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Corey, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	098401 10.60  51.0  540.60
Enter the number of hours the employee workedThis is a program to calculate gross pay.
You will be prompted for employee data.

Enter clock number for employee: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Corey, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	098401 10.60  51.0  540.60
Enter the number of hours the employee workedThis is a program to calculate gross pay.
You will be prompted for employee data.

Enter clock number for employee: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Corey, C Programming, First Homework Assignment


	----------------------------------------------------------
	Clock # Wage Hours Gross
	----------------------------------------------------------
	098401 10.60  51.0  540.60
Enter the number of hours the employee workedThis is a program to calculate gross pay.
You will be prompted for employee data.

Enter clock number for employee: Enter weekly wage for employee: Enter the number of hours the employee worked: 
		Corey, C Programming, First Homework Assignment


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