What's wrong with my logic (Java syntax)

Posted by soda on Stack Overflow See other posts from Stack Overflow or by soda
Published on 2010-05-06T01:34:39Z Indexed on 2010/05/06 1:38 UTC
Read the original article Hit count: 245

Filed under:
|

I'm trying to make a simple program that picks a random number and takes input from the user. The program should tell the user if the guess was hot (-/+ 5 units) or cold, but I never reach the else condition.

Here's the section of code:

    public static void giveHint (int guess) {
    int min = guess - 5;
    int max = guess + 5;
    if ((guess > min) && (guess < max)) {
        System.out.println("Hot..");
    } else {
        System.out.println("Cold..");
    }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about logic