Is there a way to change boolean into integers?
Like... making every "TRUE" = 1 and "FALSE" = 0
If there is a way, how will you do it?
I tried using this 'cast' thing, but it's confusing :'(
- - - - -
I'm suppose to make a table, which I did..
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));
}
}
(Sorry, I don't know how to make it into that box thingy, so I just made it green color)
The next step tells me to:
"On your own, try modifying the program so that it uses and displays 1's and 0's, rather than true and false. This may involve a bit more effort than you might at first think!"
Yeah, ignore the "On your own" part :)
__________
Thanks guys, I will get the hang of this soon enough... I hope... :S