0

Check50 is driving me nuts!

When I key in change required is 41 cents (0.41) my code produces the answer 4. i.e 1 x 25c, 1 x 10c, 1 x 5c, 1 x 1c. Maybe I am just dumb? 4 coins seems to be the smallest number for this amount of change. Is Check50 wrong, or is it my logic that is wrong?

Thanks for any help.

Gaz

6
  • Can you add your check50 results to the post? Maybe you have some extra characters that is causing check50 to fail. You cannot add text to the output, it must match the spec (instructions) exactly as written ie we ask that your program’s last line of output be only the minimum number of coins possible: an integer followed by \n. Jun 24 '16 at 19:07
  • I don't know how to add the check50 results to this post. Posting / blogging are totally alien / new to me. It took me 15 minutes to get an application to join stack exchange + another 2 days before I was accepted. Jun 25 '16 at 21:05
  • :) greedy.c exists :) greedy.c compiles :( input of 0.41 yields output of 4 \ expected output, but not "4" :( input of 0.01 yields output of 1 \ expected output, but not "1" :( input of 0.15 yields output of 2 \ expected output, but not "2" :( input of 1.6 yields output of 7 \ expected output, but not "7" :( input of 23 yields output of 92 \ expected output, but not "92" :( input of 4.2 yields output of 18 \ expected output, but not "22" :) rejects a negative input like -.1 :) rejects a non-numeric input of "foo" :) rejects a non-numeric input of "" Jun 25 '16 at 21:10
  • latest output- :) greedy.c exists :) greedy.c compiles :) input of 0.41 yields output of 4 :) input of 0.01 yields output of 1 :) input of 0.15 yields output of 2 :) input of 1.6 yields output of 7 :) input of 23 yields output of 92 :( input of 4.2 yields output of 18 \ expected output, but not "22\n" :) rejects a negative input like -.1 :) rejects a non-numeric input of "foo" :) rejects a non-numeric input of "" Jun 25 '16 at 21:19
  • Thanks for the help DinoCoderSaurus - by the way, love the handle. As you can see from the latest output your comment about the new line character in the printf function was spot on. Just one more logic problem of my own making to solve now. If there is a way for me to vote for you in this exchange, please let me know how. Jun 25 '16 at 21:27
1

Maybe you have some extra character(s) that is causing check50 to fail. You cannot add text to the output, it must match the spec (instructions) exactly as written ie

we ask that your program’s last line of output be only the minimum number of coins possible: an integer followed by \n.

You must log in to answer this question.

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