//******************************************************** // Programmazione, M.A.Alberti // Esercizio 2 - compitino 10 dicembre 2003. // Il programma Test2.java per verificare l'equivalenza di // due espressioni booleane. // Crea la tabella di verità di una delle due. //******************************************************** public class Test2 { private static boolean a, b, c; public static void main (String [] args) { if ((a && (b || c)) == ((!c || !b) && !a)) System.out.println("Sono equivalenti"); else System.out.println("Non sono equivalenti"); if ((a && (b || c)) == !((!c || !b) && !a)) System.out.println("Sono complementari"); else System.out.println("Non sono complementari"); System.out.println ("a" + "\tb "+ "\tc " + "\tb||c "+ "\t\ta&&(b||c) " + "\t(!c&&!b) " + "\t(!c&&!b)||!a "); boolean test1=false; for (int i=1; i<=2; i++) { a = test1; boolean test2=false; for (int j=1; j<=2; j++) { b = test2; boolean test3=false; for (int z=1; z<=2; z++) { c = test3; System.out.println ("" + a + "\t" + b + "\t" + c + "\t" +(b||c) + "\t" +"\t" +(a&&(b||c)) + "\t" +"\t" +(!c&&!b) + "\t" +"\t" +((!c && !b)|| !a)); test3=true; }; test2=true; }; test1=true; }; } }