(Homework Solution): Write a program with a language of your choice that produces a truth table for the

I am trying to write a program to solve this problem for discrete math. I am trying to code the program in Java. We need to produce a truth table. One of the restrictions is that we are not allowed to use any logical operators in our functions. (&&, ||, !). Also, I want to make sure I print out “true” and “false” on the table. Not “1” and “0”. It looks like the table listed below.

Write a program with a language of your choice that produces a truth table for the following proposition: NOTE 1/ Your program must have the following functions: boolean implication( boolean p, boolean q) boolean or(boolean p, boolean q) boolean and(boolean p, boolean boolean biconditional(boolean p, boolean q) boolean negation(boolean p) q) 2/ Do not use || and && in your functions. 3/ Your program should use only six columns (one for each variable, and one for the given proposition.

Write a program with a language of your choice that produces a truth table for the following proposition: NOTE 1/ Your program must have the following functions: boolean implication( boolean p, boolean q) boolean or(boolean p, boolean q) boolean and(boolean p, boolean boolean biconditional(boolean p, boolean q) boolean negation(boolean p) q) 2/ Do not use || and && in your functions. 3/ Your program should use only six columns (one for each variable, and one for the given proposition.

Expert Answer

answers

I computed p->q as x1 r^t as x2 s'(negation s) as x3 x4 as x1<->x2 and result as

x4 v x3.

Solution:

public class TruthTable {

public static void main(String[] args) {

TruthTable tt=new TruthTable();

System.out.println(“Truth table for the expression isn”);

System.out.println(“ptqtrtstttexpression”);

boolean p,q,r,s,t,x1,x2,x3,x4,result;

int n;

int values[]=new int[6];

for(int i=0;i<32;i++)

{

n=i;

for(int j=0;j<5;j++)

{

values[j]=n%2;

n=n/2;

}

if(values[0]==0)

t=false;

else

t=true;

if(values[1]==0)

s=false;

else

s=true;

if(values[2]==0)

r=false;

else

r=true;

if(values[3]==0)

q=false;

else

q=true;

if(values[4]==0)

p=false;

else

p=true;

x1=tt.implication(p, q);

x2=tt.and(r, t);

x3=tt.negation(s);

x4=tt.biconditional(x1, x2);

result=tt.or(x4, x3);

System.out.println(p+”t”+q+”t”+r+”t”+s+”t”+t+”t”+result);

}

}

boolean implication(boolean p,boolean q)

{

if(p==false)

{

return true;

}

else

{

if(q==true)

return true;

else

return false;

}

}

boolean or(boolean p,boolean q)

{

if(p==true)

return true;

else

{

if(q==true)

return true;

else

return false;

}

}

boolean and(boolean p,boolean q)

{

if(p==false)

return false;

else

{

if(q==true)

return true;

else

return false;

}

}

boolean biconditional(boolean p,boolean q)

{

if(p==true)

{

if(q==true)

return true;

else

return false;

}

else

{

if(q==false)

return true;

else

return false;

}

}

boolean negation(boolean p)

{

if(p==true)

return false;

else

return true;

}

}

Output:

eclipse-workspace TruthTable/src/TruthTable.java Eclipse IDE File Edit Source Refactor Navigate Search Project Run Window Help Quick Access! : 요 Problems @Javadoc [やDeclaration (일 Console <terminated> Truth Ta ogram Files Vavalire1.8.0 18 bin javaw.exe (Sep 30, 2018, 3:32:01 P Truth table for the expression 1s ble (Jave Application] CAP expression false false false false false true false false false false true true false false false true false false false falsc fals truc truefals false false true false false true false false truefalse true true false false trt false false false falsc true truc truetrue false trufalse false false true false trealse false true true false truefalse true false false false true als truc truefals false trutrue false false true false tretruefalse true true false truetrt false false false truetrue truc truetrue true false false false false true true false false false true true true false false true false true true falsc fals truc truetrue true false true false false true true false truefalse true true true false trt false true true falsc true truc truefals true trufalse false false true true trealse false true true true truefalse true false false true true als truc truefals true trutrue false false true true tretruefalse true true true truetruetrue false false true true truc true truc true O Type here to search 3:41 PM 9/30/2018

iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents