Wednesday, 4 December 2013

Unknown

Compare Two Numbers using else-if


/*
 Compare Two Numbers Java Example
 This Compare Two Numbers Java Example shows how to compare two numbers
 using if else if statements.
 */

public class CompareTwoNumbers {

    public static void main(String[] args) {
//declare two numbers to compare
        int num1 = 324;
        int num2 = 234;
        if (num1 > num2) {
            System.out.println(num1 + " is greater than " + num2);
        } else if (num1 < num2) {

            System.out.println(num1 + " is less than " + num2);
        } else {
            System.out.println(num1 + " is equal to " + num2);
        }
    }
}
/*
Output of Compare Two Numbers Java Example would be
324 is greater than 234
*/

Unknown

About Blog No Baap -

Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.

Subscribe to this Blog via Email :