I\'m trying to print some truth tables as part of a school assignment. How can I generate a dynamic size truth table in Java?
So that printTruthTable(1)
printTruthTable(1)
This is not a truth table - rather, it's a table of binary numbers. You can use Java's Integer.toBinaryString method to generate the zeros and ones that you need; inserting spaces should be trivial.
Integer.toBinaryString
int n = 3; for (int i = 0 ; i != (1<