summaryrefslogtreecommitdiff
path: root/wk1/pset1/cash
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2023-12-04 03:51:36 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2023-12-04 03:51:36 +0000
commite6e52e69ba7ff5566cf65ceaf6b9c8c1da962c79 (patch)
treec695e9b21e54f470b488d320ace573622948e9c0 /wk1/pset1/cash
parent07a58903b57b7e98c0b1a12ca38779ddf3e4ded3 (diff)
Sun, Dec 3, 2023, 7:51 PM -08:00
Diffstat (limited to 'wk1/pset1/cash')
-rw-r--r--wk1/pset1/cash/cash.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/wk1/pset1/cash/cash.c b/wk1/pset1/cash/cash.c
new file mode 100644
index 0000000..ac897cf
--- /dev/null
+++ b/wk1/pset1/cash/cash.c
@@ -0,0 +1,66 @@
+#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)
+{
+ // TODO
+ return 0;
+}
+
+int calculate_quarters(int cents)
+{
+ // TODO
+ return 0;
+}
+
+int calculate_dimes(int cents)
+{
+ // TODO
+ return 0;
+}
+
+int calculate_nickels(int cents)
+{
+ // TODO
+ return 0;
+}
+
+int calculate_pennies(int cents)
+{
+ // TODO
+ return 0;
+}