Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago