-
Notifications
You must be signed in to change notification settings - Fork 0
/
JudgeScore.java
105 lines (93 loc) · 4.9 KB
/
JudgeScore.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
public class JudgeScore {
public static void main(String[] args) {
//Declaring the variables for storing the judges scores.
int judge1, judge2, judge3, judge4;
judge1 = Integer.valueOf(args[0]);
judge2 = Integer.valueOf(args[1]);
judge3 = Integer.valueOf(args[2]);
judge4 = Integer.valueOf(args[3]);
/* The 24 different combinations for the size of the values of judge1, judge2, judge3,
* and judge4 are displayed below.
* NOTE: a typecast to double is used in the print statement so that a value such as
* 2.5 will give 2.5 and not be rounded down to 2.
* NOTE: else if is started on a new line instead of right after the closed curly brace
* of the previous if statement for better readability of the code.
*/
// the 6 combinations for judge 4 being the largest value
if ((judge1 <= judge2) && (judge2 <= judge3) && (judge3 <= judge4)) {
System.out.println((double) (judge2 + judge3)/2);
}
else if ((judge2 <= judge1) && (judge1 <= judge3) && (judge3 <= judge4)) {
System.out.println((double) (judge1 + judge3)/2);
}
else if ((judge1 <= judge3) && (judge3 <= judge2) && (judge2 <= judge4)) {
System.out.println((double) (judge2 + judge3)/2);
}
else if ((judge3 <= judge1) && (judge1 <= judge2) && (judge2 <= judge4)) {
System.out.println((double) (judge1 + judge2)/2);
}
else if ((judge2 <= judge3) && (judge3 <= judge1) && (judge1 <= judge4)) {
System.out.println((double) (judge1 + judge3)/2);
}
else if ((judge3 <= judge2) && (judge2 <= judge1) && (judge1 <= judge4)) {
System.out.println((double) (judge1 + judge2)/2);
}
// the 6 combinations for judge3 being the largest value
else if ((judge1 <= judge2) && (judge2 <= judge4) && (judge4 <= judge3)) {
System.out.println((double) (judge2 + judge4)/2);
}
else if ((judge2 <= judge1) && (judge1 <= judge4) && (judge4 <= judge3)) {
System.out.println((double) (judge1 + judge4)/2);
}
else if ((judge1 <= judge4) && (judge4 <= judge2) && (judge2 <= judge3)) {
System.out.println((double) (judge4 + judge2)/2);
}
else if ((judge4 <= judge1) && (judge1 <= judge2) && (judge2 <= judge3)) {
System.out.println((double) (judge1 + judge2)/2);
}
else if ((judge2 <= judge4) && (judge4 <= judge1) && (judge1 <= judge3)) {
System.out.println((double) (judge1 + judge4)/2);
}
else if ((judge4 <= judge2) && (judge2 <= judge1) && (judge1 <= judge3)) {
System.out.println((double) (judge1 + judge2)/2);
}
// the 6 combinations for judge2 being the largest value
else if ((judge1 <= judge4) && (judge4 <= judge3) && (judge3 <= judge2)) {
System.out.println((double) (judge3 + judge4)/2);
}
else if ((judge4 <= judge1) && (judge1 <= judge3) && (judge3 <= judge2)) {
System.out.println((double) (judge1 + judge3)/2);
}
else if ((judge1 <= judge3) && (judge3 <= judge4) && (judge4 <= judge2)) {
System.out.println((double) (judge3 + judge4)/2);
}
else if ((judge3 <= judge1) && (judge1 <= judge4) && (judge4 <= judge2)) {
System.out.println((double) (judge1 + judge4)/2);
}
else if ((judge4 <= judge3) && (judge3 <= judge1) && (judge1 <= judge2)) {
System.out.println((double) (judge1 + judge3)/2);
}
else if ((judge3 <= judge4) && (judge4 <= judge1) && (judge1 <= judge2)) {
System.out.println((double) (judge1 + judge4)/2);
}
// the 6 combinations for judge1 being the largest value
else if ((judge4 <= judge2) && (judge2 <= judge3) && (judge3 <= judge1)) {
System.out.println((double) (judge2 + judge3)/2);
}
else if ((judge2 <= judge4) && (judge4 <= judge3) && (judge3 <= judge1)) {
System.out.println((double) (judge3 + judge4)/2);
}
else if ((judge4 <= judge3) && (judge3 <= judge2) && (judge2 <= judge1)) {
System.out.println((double) (judge3 + judge2)/2);
}
else if ((judge3 <= judge4) && (judge4 <= judge2) && (judge2 <= judge1)) {
System.out.println((double) (judge2 + judge4)/2);
}
else if ((judge2 <= judge3) && (judge3 <= judge4) && (judge4 <= judge1)) {
System.out.println((double) (judge3 + judge4)/2);
}
else if ((judge3 <= judge2) && (judge2 <= judge4) && (judge4 <= judge1)) {
System.out.println((double) (judge2 + judge4)/2);
}
}
}