-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlargest_in3.java
More file actions
32 lines (31 loc) · 1.04 KB
/
Copy pathlargest_in3.java
File metadata and controls
32 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// to find the largest among three numbers x,y, and z.
// You should use if-then-else construct in Java.
import java.util.Scanner;;
public class largest_in3
{
public static void main(String[] args) {
try (Scanner s = new Scanner(System.in)) {
System.out.print("Enter the first number : ");
int x = s.nextInt();
System.out.print("Enter the Second number : ");
int y = s.nextInt();
System.out.print("Enter the third number : ");
int z = s.nextInt();
int result = 0;
if(x>=y && x>=z)
{
System.out.println("Largest no is : First Number");
result=x;
}
else if(y>=x && y>=z)
{
System.out.println("Largest no is : Second Number");
result=y;
}
else
System.out.println("Largest no is : Third Number");
result=z;
System.out.println("Number : "+result);
}
}
}