identify the input that is multiple of 11 and odd or even java

Posted by Bolor Ch on Stack Overflow See other posts from Stack Overflow or by Bolor Ch
Published on 2012-09-16T03:25:07Z Indexed on 2012/09/16 3:37 UTC
Read the original article Hit count: 196

Filed under:

i am trying to write code to determine the nature of input using if statement only. The nature of input could be following:

  • a multiple of 11
  • even or odd.

For the code below, when I enter my input, it does not display the result as "input:NOT:ODD". Also how can I check multiple conditions with if statement? (else is not considered)

import java.util.Scanner;
public class test
{
    public static void main( String args[] )
    {
        Scanner input = new Scanner( System.in );
        int x;
        int EO;
        int Mult;
        System.out.print ( "Enter value: " );
        x = input.nextInt();
        EO = x % 2;
        Mult = x % 11;
        if (EO > 0 && Mult > 0)
        {
            System.out.printf ("%d:NOT:ODD");
        }
    }
}

© Stack Overflow or respective owner

Related posts about java