// Exercise 3.4 (Parts 4a & 4b, for example).
// (from the Carter book).
// Use De Morgan's Laws (to simplify boolean expressions) and keep
// in mind the fact thata double negative value (!!p) is really equal
// to the positive value for that variable (p). Explain why the simpler
// boolean expression equals its original expression.
public class BooleanOperators4
{
public static void main (String[] args)
{
boolean p = true, q = false, r = false, s = true;
int x = 1, y = 2;
// Part (4a) --> for example:
System.out.println ("not (p and not q)? --> " + (!(p && !q)));
System.out.println ("is replaced by ??? ");
System.out.println ("p and q? --> " + (p && q));
System.out.println ("");
// Part (4b):
System.out.println ("not (not p and not q)? --> " + (!(!p && !q)));
System.out.println ("is replaced by ??? ");
} // main method
} // BooleanOperators4 class
No comments:
Post a Comment