Answer the question
In order to leave comments, you need to log in
How to change the code?
Hello! Let's get to the question. I am learning Java from the book by Herbert Schildt, and now, having approached the next example for testing, I ran into a problem.
Given:
class LogicalOpTable {
public static void main(String args[]) {
boolean p, q;
System.out.println("P\tQ\tAND\tOR\tXOR\tNOT");
p = true; q = true;
System.out.print(p + "\t" + q + "\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));
p = true; q=false;
System.out.print(p + "\t" + q + "\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));
p = false q = true;
System.out.print(p + "\t" + q + "\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));
p = false q=false;
System.out.print(p + "\t" + q + "\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));
}
}
Required:
Change "false" and "true" to "0" and "1" - that is, instead of "true" and "false" should be "1" and "0"
Answer the question
In order to leave comments, you need to log in
In theory, it is enough to replace
with
and further in the code in the places of initialization of variables,
replace true with 1, and false with 0
p = 1;
q = 0;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question