Print the greatest number among the three by taking the input from the user.
Code
public class greatest3 {public static void main(String args[]){Scanner a = new Scanner(System.in);System.out.println("Enter the First Number");int n1 = a.nextInt();System.out.println("Enter the Second Number");int n2 = a.nextInt();System.out.println("Enter the Third Number");int n3 = a.nextInt();if(n1>n2 && n1>n3){System.out.println(" Greatest Number is "+n1);}if(n2>n1 && n2>n3){System.out.println(" Greatest Number is "+n2);}if(n3>n1 && n3>n2){System.out.println(" Greatest Number is "+n3);}}}
Output
Greatest Number is 53
0 Comments