// // full adder: inputs A, B, Cin; outputs Sum and Cout // // The method main is basically just code to invoke FA.compute () // 8 times, with all 8 possible values for the three boolean parameters. // public class FullAdder { public static void main (String[] args) { static boolean[] A={false,true}, B={false,true}, Cin={false,true}; FAclass FA = new FAclass(); for (int i=0; i<2; i++) { for (int j=0; j<2; j++) { for (int k=0; k<2; k++) { FA.compute(A[i],B[j],Cin[k]); System.out.println ("A=" + A[i] + "\tB=" + B[j] + "\tCin=" + Cin[k] + "\tSum=" + FA.Sum + "\tCout=" + FA.Cout ); } } } } class FAclass { boolean Sum, Cout; void compute (boolean A, boolean B, boolean Cin) { Sum = (A ^ B) ^ Cin; Cout = (A & B) | (A & Cin) | (B & Cin); } } }