Learn to Program with Java version 11 - Part 11 : Write Java conditions #getajobinit

3 years ago
38

Learn to Program with Java version 11 - Part 11 : Write Java conditions

class Condition
{

public static void main(String[] args) {

int num1 = 4 ;
int num2 = 2 ;
String result ;
result = ( num1 % 2 != 0 ) ? " odd " : " even" ;
System.out.println(num1 + " is" + result );
result = ( num2 % 2 != 0 ) ? " odd" : "even" ;
System.out.println(num2 + " is " + result );

}

}

Loading comments...