Posted by : Unknown Monday, 15 June 2015

import java.util.Scanner;
class compare
 {
    public static void main( String args[] )
    {
        Scanner input = new Scanner( System.in );
        int number1,number2;
        System.out.print( "Enter first integer: " );
        number1 = input.nextInt();
        System.out.print( "Enter second integer: " );
        number2 = input.nextInt();
        if ( number1 == number2 ) {
            System.out.printf( "%d == %d\n", number1, number2 );
        }
        if ( number1 != number2 ) {
            System.out.printf( "%d != %d\n", number1, number2 );
        }
        if ( number1 < number2 ) {
            System.out.printf( "%d < %d\n", number1, number2 );
        }
        if ( number1 > number2 ) {
            System.out.printf( "%d > %d\n", number1, number2 );
        }
        if ( number1 <= number2 ) {
            System.out.printf( "%d <= %d\n", number1, number2 );
        }
        if ( number1 >= number2 ) {
            System.out.printf( "%d >= %d\n", number1, number2 );
        }
    }
}

Output:



Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Translate

Popular Post

Total Pageviews

Blog Archive

- Copyright © Learning Java Program - Powered by Blogger -