Find The Maximum Number From Given 3 Numbers by using Java Program

Code:

import java.util.*;

public class MaximumNumber
{
   public static void main(String[] args)
   {
      float n1,n2,n3;

      Scanner sc = new Scanner(System.in);

      System.out.print("\nEnter The Value Of 1sr Number : ");
      n1 = sc.nextFloat();

      System.out.print("\nEnter The Value Of 2nd Number : ");
      n2 = sc.nextFloat();

      System.out.print("\nEnter The Value Of 3rd Number : ");
      n3 = sc.nextFloat();

      if(n1>n2)
      {
           if(n1>n3)
           {
                System.out.println("\n"+n1+" Is The Maximum Number\n");
           }
           else
           {
               System.out.println("\n"+n3+" Is The Maximum Number\n");
           }
      }
      else if(n2>n1)
      {
            if(n2>n3)
            {
                 System.out.println("\n"+n2+" Is The Maximum Number\n");
            }
            else
            {
                System.out.println("\n"+n3+" Is The Maximum Number\n");
            }
      }
   }
}

Output of program:


No comments

Powered by Blogger.