-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLargestNumThree.java
More file actions
36 lines (32 loc) · 1021 Bytes
/
LargestNumThree.java
File metadata and controls
36 lines (32 loc) · 1021 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
/**
* LargestNumThree
*/
import java.util.Scanner;
public class LargestNumThree {
// function to fund the greatest number
static public float findGreatest(float a, float b, float c) {
float ans;
if (a > b && a > c) {
System.out.println("a is greater.");
ans = a;
} else if (b > a && b > c) {
System.out.println("b is greater.");
ans = b;
} else {
System.out.println("c is greater.");
ans = c;
}
return ans;
}
public static void main(String[] args) {
Scanner obj = new Scanner(System.in);
System.out.println("Enter the first number: ");
float x = obj.nextInt();
System.out.println(("Enter the second number: "));
float y = obj.nextInt();
System.out.println("Enter the third number: ");
float z = obj.nextInt();
float ans = findGreatest(x, y, z);
System.out.println("The greatest number is : " + ans);
}
}