fork download
  1. // Assignment Final Question 2
  2. //
  3. // Name: <Maribel Fuentes>
  4. //
  5. // Class: C Programming, <Fall 2024>
  6. //
  7. // Date: <December 2, 2024>
  8.  
  9.  
  10. #include <stdio.h>
  11.  
  12. double calculateJarAmount(int dollars, int halfDollars, int quarters, int dimes, int nickels, int pennies) {
  13. return dollars * 1.0 + halfDollars * 0.5 + quarters * 0.25 + dimes * 0.1 + nickels * 0.05 + pennies * 0.01;
  14. }
  15.  
  16. int main() {
  17. int dollars = 0, halfDollars = 11, quarters = 7, dimes = 3, nickels = 12, pennies = 17;
  18. double totalAmount = calculateJarAmount(dollars, halfDollars, quarters, dimes, nickels, pennies);
  19. printf("Total amount in the jar: $%.2f\n", totalAmount);
  20. return 0;
  21. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Total amount in the jar: $8.32