fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // **************************************************
  5. // Function: money_jar_total
  6. //
  7. // Description: Calculates the total amount of money in a jar cotaining various coins
  8. //
  9. // Parameters: dollars - amount of dollars in jar
  10. // half_dollars - amount of half dollars in jar
  11. // quarters - amount of quarters in jar
  12. // dimes- amount of dimes in jar
  13. // nickles - amount of nickles in jar
  14. // pennies - amount of pennies in jar
  15. //
  16. // Returns: total - Total amount of cash in jar as a double data type
  17. //
  18. // ***************************************************
  19. double money_jar_total(int dollars, int half_dollars, int quarters,
  20. int dimes, int nickles, int pennies)
  21. {
  22. double total =
  23. (dollars * 1.00) +
  24. (half_dollars * 0.50) +
  25. (quarters * 0.25) +
  26. (dimes * 0.10) +
  27. (nickles * 0.05) +
  28. (pennies * 0.01);
  29.  
  30. return total;
  31. }
  32. double total_amount = money_jar_total(0,11,7,3,12,17);
  33. printf("The total amount in the jar is $%.2f\n", total_amount);
  34. return 0;
  35.  
  36. }
  37.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
The total amount in the jar is $8.32