0

This program works fine. But check50 show this errors. Anyone can help me please. Thanks!

check50 report:

:) water.c exists
:) water.c compiles
:) 1 minute equals 12 bottles
:) 2 minutes equals 24 bottles
:) 5 minutes equals 60 bottles
:) 10 minutes equals 120 bottles
:( rejects 0 minutes
   \ expected output, not an exit code of 0
:( rejects -1 minutes
   \ expected output, not an exit code of 0
:) rejects "foo" minutes
:) rejects "" minutes
:) rejects "123abc" minutes

And here is the code

#include <stdio.h>
#include <cs50.h>

int main (void)
{
    printf("Please enter how many minutes you spend to take a shower.\n");
    int minutes = GetInt();

    if (minutes > 0)
    {
        printf("minutes: %d\n", minutes);
        int shower = 12 * minutes;
        printf("bottles: %d\n", shower);
    }
    else
        return false;

    printf("\n");

    return false;
}
0

When the user enters an invalid value (like 0 or -1), check50 is expecting that you would reprompt the user, not simply quit the program. Investigate using a do while loop.

| improve this answer | |

You must log in to answer this question.