0

When I run Greedy on Check50 I get this feedback:

:( input of 1.6 yields output of 7
   \ expected output, but not "Your change is: \n$1.60\n7\n"

for this output & format from my Greedy program on Appliance:

Your change is: 
$1.60
7

Can anyone tell me what the problem might be? Thank you.

0

check50 is expecting the exact text, as it says in the pset:

Incidentally, so that we can automate some tests of your code, we ask that your program’s last line of output be only the minimum number of coins possible: an integer followed by \n. Consider the below representative of how your own program should behave; highlighted in bold is some user’s input.

jharvard@appliance (~/Dropbox/pset1): ./greedy
O hai!  How much change is owed?      <----- program prints this
0.41                                  <---- user types this
4                                     <------ program prints this

Even thought it says "your last line", that doesn't mean you can have any other lines before that. It should match the staff example given.

So you should be returning 7\n not Your change is: \n$1.60\n7\n

6
  • I hadn't noticed that stack exchange auto-reformatted my Greedy output. It looks like this: Sep 6 '14 at 1:42
  • yes, I've fixed the formatting. My answer still stands though. :) You can't include any other prints that check50 isn't expecting.
    – curiouskiwi
    Sep 6 '14 at 2:15
  • I don't see where I have extraneous prints. My last line of code is: printf("%d\n", num_total_coins); and the 7 is alone on the last output line. Does that seem OK? Sep 6 '14 at 2:27
  • You are also printing "Your change is \n" and "$1.60\n" check50 expects only "7\n" That's what I meant by "even though the spec says your last line must contain only the number of coins" what they really mean is that your output can only be the number of coins with no extraneous prints, as the example shows.
    – curiouskiwi
    Sep 6 '14 at 5:15
  • I found the problem. I had a user-friendly prompt for the amount (1.60) and then reprinted the amount in the 2nd-to-last line. Making that line the direct user entry satisfies Check50 & gets :)s. Sep 6 '14 at 16:35

You must log in to answer this question.

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