What's wrong with this conditional?

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-03-08T21:43:29Z Indexed on 2010/03/08 21:51 UTC
Read the original article Hit count: 509

I am trying to make a method that tests to see if 3 lengths can make a triangle. I think i'm making some kind of syntax error but i can't figure out what it is.

Here is the relevant bit of code: (its in java)

public static void trya (int a, int b, int c)
{
    if (c>(a+b))
    {
        System.out.println ("yes") ;
    }
    else
    {
        if (b>(a+c)) 
        {
            System.out.println ("yes") ;
        }
    }
    else 
    { 
        if (a>(b+c))
        {
            System.out.println ("yes") ;
        }
    }
    else
    {
        System.out.println ("no") ;
    }

}

this is the error message i get:

tryangle.java:17: 'else' without 'if'
        else 
                ^

© Stack Overflow or respective owner

Related posts about conditional

Related posts about student-question