Computer Science, asked by ankan1920sardar, 9 months ago

write a program to enter three numbers and print the greatest number in Java

Answers

Answered by vikhyat04
11

import java.util.*;

public class Greatest number

{

   public static void main()  

   {  

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter the first number:");

        int  n1 = sc.nextInt();

       System.out.print("Enter the second number:");

       int   n2 = sc.nextInt();

       System.out.print("Enter the third number:");

       int n3 = sc.nextInt();

       if(n1 > n2 && n1 > n3)

       {

           System.out.println("Largest number is "+n1);

       }

       else if(n2 > n3&&n2>n1)

       {

           System.out.println("Largest number is "+n2);

       }

       else

       {

           System.out.println("Largest number is "+n3);

       }

 

   }

}

//PLEASE MARK BRAINIEST

Similar questions