/* write a program to print a truth table for a boolean expression. We will hard code the expression: * X AND (NOT Y OR Z) */ public class TruthTable { public static void main(String[] args) { boolean temp1, temp2, temp3; System.out.println("X\t\tY\t\tZ\t\tX AND (NOT Y OR Z)"); for(int x=0;x<=1;x++) for(int y=0;y<=1;y++) for(int z=0;z<=1;z++) { temp1=(x==0?false:true); temp2=(y==0?false:true); temp3=(z==0?false:true); System.out.println(temp1 + "\t" + temp2 + "\t" + temp3 + "\t" + computeValue(temp1, temp2, temp3)); } } // replace this method with any other to compute a different expression of 3 variables public static boolean computeValue(boolean x, boolean y, boolean z) { return x && (!y || z); } }