Question: C++ or Java De Morgan's Laws describe how mathematical statements and concepts are related through their opposites. In propositional logic, De Morgan's Laws relate conjunctions

C++ or Java

De Morgan's Laws describe how mathematical statements and concepts are related through their opposites. In propositional logic, De Morgan's Laws relate conjunctions and disjunctions of propositions through negation.

The first De Morgan's laws are:

(p q) (p q)

(p q) (p q)

Use De Morgans first law to write a program (Java or C++ or any language you wish) to show that both expressions in each case produce the same result.

((x < 5) (y >= 7)) ((i > 4) (j <= 6)).

Example input (the program should prompt the user to input the below values):

x : 7 y : 6 i : 5 j : 4

Corresponding output:

!(A and B) = true !A or !B = true !(A or B) = false !A and !B = false

_____________

You can work off of this code:

//import java.*; import java.util.Scanner; class Demorgan { int x,y,i,j; void readNumbers() { Scanner Sc = new Scanner(System.in); System.out.print("x : "); x = Sc.nextInt(); System.out.print("y : "); y = Sc.nextInt(); System.out.print("i : "); i = Sc.nextInt(); System.out.print("j : "); j = Sc.nextInt(); } void FirstLaw() { boolean result; result = YOUR CODE HERE System.out.println("!(A and B) = "+result); result = YOUR CODE HERE System.out.println("!A or !B = "+result); } void SecondLaw() { boolean result; YOUR CODE HERE (PERFORM THE SAME STEPS AS ABOVE) } } class Demor { public static void main(String[] args) { Demorgan obj = new Demorgan();

obj.readNumbers(); obj.FirstLaw(); obj.SecondLaw(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!