Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with the following question (rewrite '(or a (and b (not (or c d))))) --> (OR A (AND B (AND (NOT C) (NOT

I need help with the following question

(rewrite '(or a (and b (not (or c d))))) --> (OR A (AND B (AND (NOT C) (NOT D)))) (rewrite '(and a (or b (not (and c (and d e)))))) --> (AND A (OR B (NOT C) (OR (NOT D) (NOT E))))) 

Here is my solution

import java.io.*; import java.lang.String; public class Morganslaw { public static void main(String[]args) { String c="(or a (and b (not ( or c d ))))"; String b="(and a (or b (not (and c (and d e))))))";// the given strings String a=test(c);// method call to get sollution of given program and this method works any string you given System.out.println(a+" "); a=test(b);//method call to get sollution of given program System.out.println(a);// printing updated string } public static String test(String d)// method defination to find solution of given problem { System.out.println("the given String is:"); System.out.println(d+" ");// print the given String d = d.replace("(not ( or c d ))))", "(not c) (not d))))"); d=d.replace("(not (and c (and d e))))))", "(not c) (or (not d) (not e)))))"); String s1=d.toUpperCase(); // converting lower case to uppercase System.out.println("the output/updated String is:"); return s1;//return updated string to main function } }

However, with my solution you have to manually manipulate each string using the replace method. I need a function that can take in any string and de morganfy it.

For example, if you have 20 strings I wouldn't want to use the replace method 20 times. I need the function to use demorgan law to find an equivalent expression

Please help thanks

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_2

Step: 3

blur-text-image_3

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

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions

Question

Describe the five elements of the listening process.

Answered: 1 week ago