fork(1) download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Rose Locarno
  6. //
  7. // Class: C Programming, Summer 2023
  8. //
  9. // Date: May 23 2023
  10. //
  11. // Description: Program which determines gross pay and outputs
  12. // to the screen. This version does not use file pointers
  13. //
  14. // Non file pointer solution
  15. //
  16. //********************************************************
  17.  
  18. #include <stdio.h>
  19. int main ()
  20. {
  21.  
  22. int clock_num; // employee clock number
  23. float grossPay; // gross pay for week (wage * hours)
  24. float hours; // number of hours worked per week
  25. float wage; // hourly wage
  26.  
  27. printf ("\n\t*** Pay Calculator ***\n");
  28.  
  29. // Prompt for input values from the screen
  30. printf ("\n\tEnter clock number for employee: ");
  31. scanf ("%d", &clock_num);
  32. printf ("\n\tEnter hourly wage for employee: ");
  33. scanf ("%f", &wage);
  34. printf ("\n\tEnter the number of hours the employee worked: ");
  35. scanf ("%f", &hours);
  36.  
  37. // calculate gross pay
  38. grossPay = wage * hours;
  39.  
  40. // print out employee information
  41. printf ("\n\n\t----------------------------------------------------------\n");
  42. printf ("\tClock # Wage Hours GrossPay\n");
  43. printf ("\t----------------------------------------------------------\n");
  44.  
  45. printf ("\t%06i %5.2f %5.1f %7.2f\n",clock_num, wage, hours, grossPay);
  46.  
  47.  
  48.  
  49. return (0); // success
  50.  
  51. } // main
Success #stdin #stdout 0.01s 5456KB
stdin
98401 10.60 51.0
526488 9.75 42.5
765349 10.50 37.0

stdout
	*** Pay Calculator ***

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

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