class Truth { private static boolean NAND[] = { true, true, true, false } ; private static boolean Func1(boolean P, boolean Q) { // This one is wrong return(false) ; } private static boolean IMPL[] = { true, true, false, true } ; private static boolean Func2(boolean P, boolean Q) { // This one is wrong return(false) ; } // You may ignore anything that follows this comment private static String b2c(boolean B) { return B ? "T" : "F" ; } private static boolean PI1(int I) { return I>=2 ; } private static boolean PI2(int I) { return I%2 == 1 ; } public static void main(String args[]) { int i ; System.out.println("NAND") ; for (i=0; i<4; ++i) { boolean P = PI1(i) ; boolean Q = PI2(i) ; boolean R = Func1(P, Q) ; System.out.print(" " + b2c(P) + " " + b2c(Q) + " " + b2c(R)) ; System.out.println(R==NAND[i] ? "" : " WRONG!") ; } System.out.println() ; System.out.println("Implies") ; for (i=0; i<4; ++i) { boolean P = PI1(i) ; boolean Q = PI2(i) ; boolean R = Func2(P, Q) ; System.out.print(" " + b2c(P) + " " + b2c(Q) + " " + b2c(R)) ; System.out.println(R==IMPL[i] ? "" : " WRONG!") ; } } }