Computer Science, asked by rekhaverma02021975, 11 months ago

Write a program in Java to find the greatest of three numbers using ternary operator.

Answers

Answered by dineshkannan135
5

public class JavaExample  

{

   public static void main(String[] args)  

   {

       int num1, num2, num3, result, temp;

       Scanner scanner = new Scanner(System.in);

       System.out.println("Enter First Number:");

       num1 = scanner.nextInt();

       System.out.println("Enter Second Number:");

       num2 = scanner.nextInt();

       System.out.println("Enter Third Number:");

       num3 = scanner.nextInt();

       scanner.close();

       

       

       temp = num1>num2 ? num1:num2;

       result = num3>temp ? num3:temp;

       System.out.println("Largest Number is:"+result);

   }

}

Answered by JyotismitaMajhi
3

Answer:

hope it helped you and you like it and plz follow me and marked it as brainlist

Attachments:
Similar questions