fork download
  1. //*******************************************************
  2. //
  3. // Homework: 1 (Chapter 4/5)
  4. //
  5. // Name: Blake Shetler
  6. //
  7. // Class: C Programming, Fall 2024
  8. //
  9. // Date: 09/14/2024
  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.  
  20. int main()
  21. {
  22. //declare variables
  23. int clock_number;
  24. float wage_rate;
  25. float hours_worked;
  26. float gross_pay;
  27.  
  28. //prompt employee to enter clock ID, hourly rate, and hours worked
  29. printf("\t ~~~~~~~~ Pay Calulator ~~~~~~~~\n");
  30.  
  31. printf("Enter employee's clock number: \n");
  32. scanf("%d", &clock_number);
  33.  
  34. printf("Enter hourly wage for employee: \n");
  35. scanf("%f", &wage_rate);
  36.  
  37. printf("Enter the number of hours the employee worked this week: \n");
  38. scanf("%f", &hours_worked);
  39.  
  40. //calucation for gross pay
  41. gross_pay = wage_rate * hours_worked;
  42.  
  43. //printing out results
  44. printf("\t=========================\n");
  45. printf("\tClock# Wage Hours Gross\n");
  46. printf("\t=========================\n");
  47.  
  48. printf("\t%06i %.2f % 2.1f % 6.2f", clock_number, wage_rate, hours_worked, gross_pay);
  49.  
  50. return(0);
  51. }
Success #stdin #stdout 0s 5280KB
stdin
526488
9.75
42.5
stdout
	 ~~~~~~~~ Pay Calulator ~~~~~~~~
Enter employee's clock number: 
Enter hourly wage for employee: 
Enter the number of hours the employee worked this week: 
	=========================
	Clock# Wage  Hours Gross
	=========================
	526488 9.75  42.5  414.38