I am currently working on an assignment for school but I'm lost when it comes to implementing into code.
The idea of the assignment is to create multiple True
and False
tables of (p
, q
, r
, Proposition
). The values p
, q
, r
, can be hard coded in meaning I can just create an array with the values and I do not have to worry about those. But when it comes to the last array proposition
I have to create all possible combinations out of an array length 8 and print them out.
The thing is I been searching and I can't find something related to this. I'm not asking to do the assignment for me but I want know if someone can explain to me how is it done. This is so far the code I have made it's not much but you can actually tell I'm stuck, also when I asked they told me it's possible to do it in 8 nested loops so I'm currently working on this feedback is appreciated. Thanks
public class truthTables {
public static void main(String[] args) {
boolean t = true;
boolean f = false;
boolean[] p = {f, f, f, f, t, t, t, t};
boolean[] q = {f, f, t, t, f, f, f, f};
boolean[] r = {f, t, f, t, f, t, f, t};
boolean[] proposition = new boolean[8];
int tableNumber = 1;
while (tableNumber <= 256) {
System.out.println("Table " + tableNumber + " ");
System.out.println("P " + " q " + " r " + " proposition ");
System.out.println("________________");
int i = 0;
while (i <= 7) {
i = i;
if (proposition[i] = true) {
System.out.println(p[i] + " " + q[i] + " " + r[i] + " " + proposition[i]);
}
if (proposition[i] = false) {
System.out.println(p[i] + " " + q[i] + " " + r[i] + " " + proposition[i]);
}
i = i + 1;
}
tableNumber = tableNumber + 1;
}
}
}