Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started