Computer Science, asked by pratapndhal2010, 8 months ago

Write a program in java scanner class to input 3 nos and check if they are equal or not.If they are unequal find the second largest number. If equal display "All nos are equal".(Use Nested If)​

Answers

Answered by pavithranatarajan855
0

Answer:

import java.util.*;

public class Programming{

   public static void main(String args[]){

       Scanner s=new Scanner(System.in);

       System.out.println("Program started");

       int var1=s.nextInt();

       int var2=s.nextInt();

       int var3=s.nextInt();

       if(var1==var2 && var2==var3 && var3==var1)

       System.out.println("All nos are equal");

       else

       {

           if(var1>var2){

               if(var3>var1)

               System.out.println("var1 is second largest");

           else if(var2>var3){

               if(var1>var2)

               System.out.println("var2 is second largest");

           else

              System.out.println("var3 is second largest");

               

           }

           }

       }

   }

}

Explanation:

Similar questions