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 );
}
}
}
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:
Related Posts :
- Back to Home »
- Example program , Simple Program »
- Comparing two numbers