Mario and Greedy seems to output the same errors for me. It is frustrating, because they do what they are "supposed" to do. So I can't figure out how to solve the error. I looked through the others question, regarding this problem. But did not find a solution.

IF you haven't completed these assignments, I will strongly recommend, you do not open the codes. You will learn so much more, if you push your self to complete them.

Greedy code: https://codeshare.io/Uagyj Mario code: https://codeshare.io/no6eI

Greedy CS50 CHECK:

:) 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
:( rejects a negative input like -.1
   \ expected prompt for input, not exit code of 0
:) rejects a non-numeric input of "foo"
:) rejects a non-numeric input of ""

Mario CS50 CHECK:

:) mario.c exists
:) mario.c compiles
:) rejects a height of -1
:( handles a height of 0 correctly
   \ expected an exit code of 0, not output of "Height: "
:) handles a height of 1 correctly
:) handles a height of 2 correctly
:( handles a height of 23 correctly
   \ expected output, but not "Height: "
:( rejects a height of 24
   \ expected output, but not "Height: "
:) rejects a non-numeric height of "foo"
:) rejects a non-numeric height of ""

Time for some tough love. The problem is that the program instructions (read that as project specifications) are not being followed. You need to do exactly what the specification says. Close isn't good enough. It's even more necessary in this environment because the psets are graded by an automated system, not a person. check50 expects exact results, not something really close.

In greedy, the instructions say: If the user fails to provide a non-negative value, your program should re-prompt the user for a valid amount again and again until the user complies. Your code doesn't do any validation of the input data, so the user can enter anything. That's causing the fail that you are seeing.

In Mario, both 0 and 23 are valid inputs that your code rejects. While the code is doing input validation, the validation isn't written to match the specification.

Your code does handle 24 correctly, but interestingly, it appears that you may have also surfaced a bug in check50. If the check for 23 fails, it looks like the check for 24 will also fail even if it is correct. I will pass this along.

In short, all of the errors are due to not following the program specification. This is an important lesson for writing code for customers and in team programming. Customers want what they want, not something close. In team programming, individual programmers work on different parts that have to all work together later, so each part has to do what is required.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thank you for your help and pointing me in the right direction :) – Dennis Jepsen Mar 31 '16 at 7:52

You must log in to answer this question.

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