Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Please show me where I went wrong? I have tried many numbers to check, but the bottom line in output still comes.

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Please show me where I went wrong? I have tried many numbers to check, but the bottom line in output still comes.

    class If{


    public static void main( String[] args )
    {
    if ( 5 > 1 ) System.out.println( "Five is greater than one." );

    if ( 2 < 4 )
    {
    System.out.println( "Two is less than four." );
    System.out.println( "Test succeeded." );
    }

    int num = 75;

    if ( (( num > 5 ) && ( num < 10 )) || ( num == 12 ) );
    System.out.println( "Number is 6-9 inclusive, or 12" );
    }



    }


    The OUTPUT is:

    Five is greater than one.
    Two is less than four.
    Test succeeded.
    Number is 6-9 inclusive, or 12


    Thanks.


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    619
    My Mood
    Sleepy
    Thanks
    10
    Thanked 94 Times in 87 Posts

    Default Re: Please show me where I went wrong? I have tried many numbers to check, but the bottom line in output still comes.

    Never ever write if statements without braces. Never ever put a semicolon at the end of an if.

Similar Threads

  1. how to add two check boxes into single line
    By starhanif in forum Java ME (Mobile Edition)
    Replies: 4
    Last Post: September 4th, 2013, 08:38 AM
  2. Show output on jTextArea
    By HugoMonteiro in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 18th, 2012, 08:35 PM
  3. How to check for shortage of command line arguments
    By IHeartProgramming in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 16th, 2012, 12:00 AM
  4. need numbers to output onto a new line
    By oscar22 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 27th, 2011, 08:32 AM
  5. Check for palindrome numbers
    By SnooSnoo in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 4th, 2010, 06:11 PM