Skip to content

Commit 13477a2

Browse files
committed
Greatest among three
1 parent 2e4a4b6 commit 13477a2

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

module1/Greatest3.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//Program to find the greatest among three numbers by using the ternary operation
2+
import java.util.Scanner;
3+
class ThreeG
4+
{
5+
public static void main(String args[])
6+
{
7+
Scanner reader = new Scanner(System.in);
8+
System.out.print("\nEnter the first number = ");
9+
int fn = reader.nextInt();
10+
System.out.print("\nEnter the second number = ");
11+
int sn = reader.nextInt();
12+
System.out.print("\nEnter the third number = ");
13+
int tn = reader.nextInt();
14+
reader.close();
15+
int result = (fn > sn ? (fn > tn ? fn: tn) : (sn > tn? sn : tn ));
16+
System.out.print("\nGreatest number among three is " + result);
17+
18+
19+
}
20+
}

0 commit comments

Comments
 (0)