-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonkeyTrouble
More file actions
24 lines (21 loc) · 893 Bytes
/
monkeyTrouble
File metadata and controls
24 lines (21 loc) · 893 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
//We have two monkeys, a and b, and the parameters aSmile and bSmile indicate if each is smiling.
// We are in trouble if they are both smiling or if neither of them is smiling. Return true if we are in trouble.
//monkeyTrouble(true, true) → true
// monkeyTrouble(false, false) → true
// monkeyTrouble(true, false) → false
public class monkeyTrouble {
public static void main(String[] args) {
boolean output=monkeyTrouble(true,true);
System.out.println(output);
boolean output1=monkeyTrouble(false,false);
System.out.println(output1);
boolean output2=monkeyTrouble(true, false);
System.out.println(output2);
}
public static boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
if ((aSmile && bSmile) || (!aSmile && !bSmile)){
return true;
}
return false;
}
}