Greatest Number Program in Java

Greatest Number Program in Java
Greatest Number Program in Java

import java.util.Scanner;
public class GreatestNumber {
    public static void main(String[] args) {
        int     n1, n2, n3;
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter n1 number=");
        n1 = sc.nextInt();
        System.out.print("Enter n2 number=");
        n2 = sc.nextInt();
        System.out.print("Enter n3 number=");
        n3 = sc.nextInt();

        if (n1 > n2) {
            if (n1 > n3) {
                System.out.println("n1 is greatest.");
            } else {
                System.out.println("n3 is greatest.");
            }
        } else {
            if (n2 > n3) {
                System.out.println("n2 is greatest.");
            } else {
                System.out.println("n3 is greatest.");
            }
        }
    }
}

Output:

Enter n1 number=15
Enter n2 number=18
Enter n3 number=10
n2 is greatest.
b. tech. bca icse java java tutorials learn java mca programs