Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to write a program to solve this problem for discrete math. I am all

ID: 3750799 • Letter: I

Question

I am trying to write a program to solve this problem for discrete math. I am allowed to use any language. I prefer to use either Java or C++. Would anyone mind helping me? We need to produce a table. One of the restrictions is that we are not allowed to use "||" and "&&" in our functions.

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.

Explanation / Answer

#include <iostream>

#include <stdbool.h>

// here 0 implies false and 1 implies true

// code is in c++

using namespace std;

bool Or(bool p , bool q)

{

if(p==1)

{

return 1;

}

else if(q==1)

return 1;

return 0;

}

bool And(bool p , bool q)

{

if(p==1)

{

if(q==1)

return 1;

}

return 0;

}

bool biconditional(bool p , bool q)

{

if(p==q)

{

return 1;

}

return 0;

}

bool implication(bool p , bool q)

{

if(q==1)

{

return 1;

}

else if(p==q)

return 1;

return 0;

}

bool negation(bool p)

{

if(p==1)

{

return 0;

}

return 1;

}

int main()

{

cout<< " " << "p" << " " << "q" << " " << "r" << " " << "s" << " " << "t" << " " << "expression" << endl;

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

{

bool p=i;

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

{

bool q=i;

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

{

bool r=i;

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

{

bool s=i;

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

{

bool t=i;

bool x = implication(p,q);

bool y = And(r,t);

x = biconditional(x,y);

x = Or(x,negation(s));

cout<< " " << p << " " << q << " " << r << " " << s << " " << t << " " << x << endl;

}

}

}

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote