I am after some help for a project I am doing pls. I am writing a program to display the truth table of a boolean expression and so far all is good. I decided to convert the input into reverse polish notation, so I could get the expression into priority order. This works. The program displays the truth table inputs, with no problems, and I am now working on the Boolean part. If you entered for eg, a+b.c, I have stored the reverse polish notation in a array. In this would be stored a b c . + in elements 0 to 4 As each row input is calculated eg a b c output
0 0 0 I then want to display the output. My first idea was to read through the array until I hit a boolean operator and then perform this with the top two variables in my stack, in this case a.b but when trying values, I can get a boolean output for and, or and xor, but not for NOT, as can be see from the attachment My program is live at http://andylittlewood.co.uk The coding I was using to test the boolean output is
echo "1 and 1 = "; echo 1 && 1;
echo "<br>1 or 1 = "; echo 1 || 1;
echo "<br> 1 xor 1 = "; echo true ^ true;
echo "<br>Not 1 = ";echo !(true);
I cannot put my full coding on here, as it is a project and do not want to plagiarise.