Answers for "greatest of three numbers in java"

0

how to do the maximum of three numbers in java

public class Example {
   public static void main(String args[]) {
      int num1 = 15;
      int num2 = -5;
      int num3 = 7;
      if (num1 >= num2 && num1 >= num3)
         System.out.println( num1 + " is the maximum number.");
      else if (num2 >= num1 && num2 >= num3)
         System.out.println( num2 + " is the maximum number.");
      else
         System.out.println( num3 + " is the maximum number.");
   }
}
Posted by: Guest on December-06-2020
0

greatest of three in java

import java.util.*;
class Main 
{
     public static void main(String[] aa){
         Scanner sc=new Scanner(System.in);
         int n1,n2,n3;
         n1=sc.nextInt();
         n2=sc.nextInt();
         n3=sc.nextInt();
         System.out.println(n1>n2 ?(n1>n3?n1:n3): (n2>n3 ? n2 : n3));
    
}
}
Posted by: Guest on June-25-2021

Code answers related to "greatest of three numbers in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language