-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFullAdder.java
More file actions
21 lines (19 loc) · 906 Bytes
/
Copy pathFullAdder.java
File metadata and controls
21 lines (19 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.Arrays;
public class FullAdder {
static boolean[] halfAdder(boolean A,boolean B,boolean Cin){
boolean[] sumCarry = new boolean[2];
sumCarry[0]=(A!=B);
sumCarry[1]=((A&B)||((A&B)&(A^B)));
return sumCarry;
}
public static void main(String[] args) {
System.out.println(Arrays.toString(halfAdder(false,false,false)));
System.out.println(Arrays.toString(halfAdder(false,false,true)));
System.out.println(Arrays.toString(halfAdder(false,true,false)));
System.out.println(Arrays.toString(halfAdder(false,true,true)));
System.out.println(Arrays.toString(halfAdder(true,false,false)));
System.out.println(Arrays.toString(halfAdder(true,false,true)));
System.out.println(Arrays.toString(halfAdder(true,true,false)));
System.out.println(Arrays.toString(halfAdder(true,true,true)));
}
}