-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXOR.java
More file actions
35 lines (27 loc) · 821 Bytes
/
Copy pathXOR.java
File metadata and controls
35 lines (27 loc) · 821 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
import java.util.Scanner;
public class XOR {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("What is the first value - true or false?");
boolean d = sc.nextBoolean();
System.out.println("What is the second value - true or false?");
boolean e = sc.nextBoolean();
boolean res = xor(d, e);
System.out.println("This set of statements are " + res);
sc.close();
}
public static boolean xor(boolean d, boolean e) {
boolean result = true;
if ((d == true) && (e == true)) {
result = false;
}else if ((d == true) && (e == false)) {
result = true;
}else if ((d == false) && (e == true)) {
result = true;
}else if ((d == false) && (e == false)) {
result = false;
}
return result;
}
}