2

I've just finished cash and it seems to be working as expected when I run a manual test. When I run Check50 though I get the following message:

:( calculate_nickels returns 5 when input is 28 expected "5", not "0"

Not sure what to do as when I input 28 I get 4 back. Any advice much appreciated :) Here is my code + screenshot

int get_cents(void)

{ int change; do { change = get_int("Change due: "); } while (change < 0); return change; }

int calculate_quarters(int cents) { int quarters = cents / 25; return quarters; }

int calculate_dimes(int cents) { int dimes = (cents % 25) / 10; return dimes; }

int calculate_nickels(int cents) { int nickels = ((cents % 25) % 10) / 5; return nickels; }

int calculate_pennies(int cents) { int pennies = ((cents % 25) % 10) % 5; return pennies; }

enter image description here

1
  • Thanks for responding @DinoCoderSaurus. I will take another look
    – geman20
    Commented Jan 10, 2022 at 13:43

1 Answer 1

1

The "coin" functions (except quarters) look like they expect (assume) cents to be the original cents entered by the user. Read through the distro code more carefully to see why that assumption is causing the wrong answer(s).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .