/* DisplayTruthTable.java Dave Klick CIS 111 2014-09-05 Displays a truth table. */ public class DisplayTruthTable extends CIS111App { public static void main(String[] args) { printf("%5s %5s %5s %5s %5s %5s %9s %9s %9s %9s\n", "A", "B", "!A", "!B", "A^B", "AvB", "!(AvB)", "(!A)^(!B)", "!(A^B)", "(!A)v(!B)"); printf("%1$5s %1$5s %1$5s %1$5s %1$5s %1$5s %2$9s %2$9s %2$9s %2$9s\n", "-----", "---------"); displayTruthiness(true, true); displayTruthiness(true, false); displayTruthiness(false, true); displayTruthiness(false, false); } private static void displayTruthiness(boolean a, boolean b) { printf("%5b %5b %5b %5b %5b %5b %9b %9b %9b %9b\n", a, b, !a, !b, a&&b, a||b, !(a||b), !a&&!b, !(a&&b), !a||!b); } } /* Output: A B !A !B A^B AvB !(AvB) (!A)^(!B) !(A^B) (!A)v(!B) ----- ----- ----- ----- ----- ----- --------- --------- --------- --------- true true false false true true false false false false true false false true false true false false true true false true true false false true false false true true false false true true false false true true true true */