-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogicalOpTable.java
More file actions
63 lines (48 loc) · 1.49 KB
/
Copy pathLogicalOpTable.java
File metadata and controls
63 lines (48 loc) · 1.49 KB
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
//2-2: Truth table for logical operators
class LogicalOpTable{
public static void main (String [] args){
boolean p,q;
int pInt, qInt, pANDq, pORq, pXORq, notP;
System.out.println("P\tQ\tAND\tOR\tXOR\tNOT");
p = true;q = true;
pInt = p ? 1:0;
qInt = q ? 1:0;
pANDq = (p&q) ? 1:0;
pORq = (p|q) ? 1:0;
pXORq = (p^q) ? 1:0;
notP = !(p) ? 1:0;
System.out.print(pInt + "\t" + qInt +"\t");
System.out.print(pANDq+"\t"+pORq+"\t");
System.out.println(pXORq+"\t"+notP);
p = true;q = false;
pInt = p ? 1:0;
qInt = q ? 1:0;
pANDq = (p&q) ? 1:0;
pORq = (p|q) ? 1:0;
pXORq = (p^q) ? 1:0;
notP = !(p) ? 1:0;
System.out.print(pInt + "\t" + qInt +"\t");
System.out.print(pANDq+"\t"+pORq+"\t");
System.out.println(pXORq+"\t"+notP);
p = false;q = true;
pInt = p ? 1:0;
qInt = q ? 1:0;
pANDq = (p&q) ? 1:0;
pORq = (p|q) ? 1:0;
pXORq = (p^q) ? 1:0;
notP = !(p) ? 1:0;
System.out.print(pInt + "\t" + qInt +"\t");
System.out.print(pANDq+"\t"+pORq+"\t");
System.out.println(pXORq+"\t"+notP);
p = false;q = false;
pInt = p ? 1:0;
qInt = q ? 1:0;
pANDq = (p&q) ? 1:0;
pORq = (p|q) ? 1:0;
pXORq = (p^q) ? 1:0;
notP = !(p) ? 1:0;
System.out.print(pInt + "\t" + qInt +"\t");
System.out.print(pANDq+"\t"+pORq+"\t");
System.out.println(pXORq+"\t"+notP);
}
}