-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBLUE_TICKET.java
More file actions
32 lines (27 loc) · 809 Bytes
/
BLUE_TICKET.java
File metadata and controls
32 lines (27 loc) · 809 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
/*
You have a blue lottery ticket, with ints a, b, and c on it.
This makes three pairs, which we'll call ab, bc, and ac.
Consider the sum of the numbers in each pair.
If any pair sums to exactly 10, the result is 10.
Otherwise if the ab sum is exactly 10 more than either bc or ac sums, the result is 5. Otherwise the result is 0.
blueTicket(9, 1, 0) → 10
blueTicket(9, 2, 0) → 0
blueTicket(6, 1, 4) → 10
*/
package school;
public class BLUE_TICKET {
public static void main(String[] args){
int answer = blueTicket(9, 1, 0);
System.out.println(answer);
}
public static int blueTicket(int a, int b, int c) {
int ab = a+b;
int bc = b+c;
int ac = a+c;
if((ab==10 || bc==10) || ac==10){
return 10;
}else if(ab-bc>=10 || ab-ac>=10){
return 5;
}return 0;
}
}