Java program to check the equality of given numbers
KW.java
import java.util.Scanner;
class KW 
{
    public static void main(String args[])
    {
        float a,b;
        Scanner sc=new Scanner(System.in);
        System.out.println("———————————————————————————————————————————");
        System.out.println("Program to check the equality of given numbers");
        System.out.println("———————————————————————————————————————————");
        System.out.print("\nEnter the 1st number ");
        a=sc.nextFloat();
        System.out.print("\nEnter the 2nd number ");
        b=sc.nextFloat();
        if(a>b)
            System.out.println("\n"+a+" is greater than "+b);
        else if(a<b)
            System.out.println("\n"+a+" is less than "+b);
        else
            System.out.println("\n"+a+" is equal to "+b);
        System.out.println("———————————————————————————————————————————");
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW ——————————————————————————————————————————— Program to check the equality of given numbers ——————————————————————————————————————————— Enter the 1st number -10 Enter the 2nd number -50 -10.0 is greater than -50.0 ——————————————————————————————————————————— kodingwindow@kw:~$
Advertisement