diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-17 22:59:23 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-17 22:59:23 +0000 |
commit | a2682d25c6cd0e069ff73a43df74c17a63caabac (patch) | |
tree | bc5621a5a4b99495a64e41d2407cc5cde22061de /wk1/pset1/cash | |
parent | d3c2d73736cc188e7ad089bfb29d42bf29faf881 (diff) |
Sat, Feb 17, 2024, 2:59 PM -08:00
Diffstat (limited to 'wk1/pset1/cash')
-rw-r--r-- | wk1/pset1/cash/cash.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/wk1/pset1/cash/cash.c b/wk1/pset1/cash/cash.c deleted file mode 100644 index 13c6889..0000000 --- a/wk1/pset1/cash/cash.c +++ /dev/null @@ -1,70 +0,0 @@ -#include <cs50.h> -#include <stdio.h> - -int get_cents(void); -int calculate_quarters(int cents); -int calculate_dimes(int cents); -int calculate_nickels(int cents); -int calculate_pennies(int cents); - -int main(void) -{ - // Ask how many cents the customer is owed - int cents = get_cents(); - - // Calculate the number of quarters to give the customer - int quarters = calculate_quarters(cents); - cents = cents - quarters * 25; - - // Calculate the number of dimes to give the customer - int dimes = calculate_dimes(cents); - cents = cents - dimes * 10; - - // Calculate the number of nickels to give the customer - int nickels = calculate_nickels(cents); - cents = cents - nickels * 5; - - // Calculate the number of pennies to give the customer - int pennies = calculate_pennies(cents); - cents = cents - pennies * 1; - - // Sum coins - int coins = quarters + dimes + nickels + pennies; - - // Print total number of coins to give the customer - printf("%i\n", coins); -} - -int get_cents(void) -{ - int i; - do - { - i = get_int("How many cents? "); - } - while (i < 0); - return i; -} - -int calculate_quarters(int cents) -{ - cents = cents / 25; - return cents; -} - -int calculate_dimes(int cents) -{ - cents = cents / 10; - return cents; -} - -int calculate_nickels(int cents) -{ - cents = cents / 5; - return cents; -} - -int calculate_pennies(int cents) -{ - return cents; -} |