write a program in Java to find the greatest of three numbers using the ternary operator
Answers
Answered by
6
Heya user
Here is your answer !!
___________
import java.util.* ;
public class Greatest
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.println ( " Enter three numbers " ) ;
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int g = ( a > b ) ? a : b ;
int G = ( g > c ) g : c ;
System.out.println ( " Greatest : " + G ) ;
}
}
___________
Hope it helps !!
Here is your answer !!
___________
import java.util.* ;
public class Greatest
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.println ( " Enter three numbers " ) ;
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int g = ( a > b ) ? a : b ;
int G = ( g > c ) g : c ;
System.out.println ( " Greatest : " + G ) ;
}
}
___________
Hope it helps !!
Incredible29:
plz follow if u lyk my answer
Similar questions