-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlargestOfThreeNumber.java
More file actions
41 lines (28 loc) · 886 Bytes
/
largestOfThreeNumber.java
File metadata and controls
41 lines (28 loc) · 886 Bytes
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
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
public class largestOfThreeNumber {
public static void main(String[] args) {
/*
Take three numbers from the user and print the largest number using if-else-if.
Example
Input: 5, 10, 7
Output: 10 is the largest.
*/
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number :");
int x = sc.nextInt();
System.out.println("Enter the number :");
int y = sc.nextInt();
System.out.println("Enter the number :");
int z = sc.nextInt();
if(x>=y && x>=z){
System.out.println(x +" is the Largest number");
}
else if(y>=x && y>=z){
System.out.println(y + " is the largest number");
}
else{
System.out.println(z + " is the largest number");
}
sc.close();
}
}