Try to search your question here, if you can't find : Ask Any Question Now ?

if else if not outputing else if statement java

HomeCategory: stackoverflowif else if not outputing else if statement java
willson asked 2 weeks ago

I have problem with else if part of the code. First “if” works fine, third (else) works fine, but I have problem with “else if” part of the code, where program don’t execute this statement.

if ((a+c)>=(b+d))
{
    if ((a==b) && (b==c) && (c==d))
    {

    System.out.println("square");

}
    else if ( (a!=b) && (c!=d)  && ( a== c) && (b == d)  )
    {
            System.out.println("rectangle");
    }

    else 
    {           

        System.out.println("four different sides");
    }

}       
        else
            System.out.println("ERROR");

So, when I enter values a=c and b=d, I get “ERROR” instead of “rectangle.

What did I do wrong?

Thanks!

1 Answers
Best Answer
Mikhail answered 2 weeks ago
Your Answer

3 + 19 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com