Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to change boolean True/False Values into 1 and 0

807599Mar 19 2007 — edited Mar 19 2007
Im stuck with this java book thing because i cant do this excercise T_T, id like to know how to change the boolean True/False values into 1/0 so it shows on screen, this is the code i have for the True False Table:

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.println(p+ "\t" + q+ "\t" + (p&q)+ "\t" +(p|q)+ "\t" +(p^q)+ "\t" + (!p)) ;

p = true ; q = false ;
System.out.println(p+ "\t" + q+ "\t" + (p&q)+ "\t" +(p|q)+ "\t" +(p^q)+ "\t" + (!p)) ;

p = false ; q = true ;
System.out.println(p+ "\t" + q+ "\t" + (p&q)+ "\t" +(p|q)+ "\t" +(p^q)+ "\t" + (!p)) ;

p = false ; q = false ;
System.out.println(p+ "\t" + q+ "\t" + (p&q)+ "\t" +(p|q)+ "\t" +(p^q)+ "\t" + (!p)) ;
}
}

Help appreciated ^__^
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2007
Added on Mar 19 2007
4 comments
2,489 views