# (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.

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:

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.

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.

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?

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

Proceed with the payment

Choose the payment system that suits you most.

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.

## 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.