Write a program to accept three numbers and find the greatest and smallest number.
import java.util.*;
public class greatestsmallest {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Enter three numbers : ");
int n1=sc.nextInt();
int n2=sc.nextInt();
int n3=sc.nextInt();
if(n1==n2&&n1==n3)
System.out.println("The numbers are equal");
else
if(n1>n2&&n1>n3)
System.out.println(n1 + " is the greatest number");
else
if(n2>n3&&n2>n1)
System.out.println(n2 + " is the greatest number");
else
if(n3>n1&&n3>n2)
System.out.println(n3 + " is the greatest number");
if(n1<n2&&n1<n3)
System.out.println(n1 + " is the smallest number");
else
if(n2<n1&&n2<n3)
System.out.println(n2 + " is the smallest number");
else
if(n3<n2&&n3<n1)
System.out.println(n3 + " is the smallest number");
}
}