-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaxOfEight.java
70 lines (68 loc) · 1.61 KB
/
MaxOfEight.java
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
public class MaxOfEight {
public static void main(String[] args) {
int a = 99, b = 91, c = 95, d = 100, e = 97, f = 94, g = 92, h = 96;
System.out.print("The max of " + a + ", " + b + ", " + c + ", " + d +
", " + e + ", " + f + ", " + g + ", " + h + " is " +
maxEight(a,b,c,d,e,f,g,h));
}
public static int maxEight(int a, int b, int c, int d, int e, int f, int g, int h) {
if (a > b) {
if (a > c) {
if (a > d) {
if (a > e) {
if (a > f) {
if (a > g) {
if (a > h)
return a;
}
}
}
}
}
}
if (b > c) {
if (b > d) {
if (b > e) {
if (b > f) {
if (b > g) {
if (b > h)
return b;
}
}
}
}
}
if (c > d) {
if (c > e) {
if (c > f) {
if (c > g) {
if (c > h)
return c;
}
}
}
}
if (d > e) {
if (d > f) {
if (d > g) {
if (d > h)
return d;
}
}
}
if (e > f) {
if (e > g) {
if (e > h)
return e;
}
}
if (f > g) {
if (f > h)
return f;
}
if (g > h)
return g;
else
return h;
}
}