Beginners Problem Boolean to Int?

Hi there, I recently bought Java: A Beginners Guide in an attempt to learn my first programming language, I completed the first chapter no problems but a question in chapter 2 has me stumped.
Try This 2-2, Display a Truth Table: Create a program that displays the truth table for Javas Logical Operators. I did this by following the example in the book:

Thats grand, but the last part of the question "modify the program so that it displays 1's and 0's rather than true or false" is where I run into problems.

I have tried lots of different ways to do this none being successful. The one that makes most sense to me is trying to cast incompatible types, which I have tried but the complier says they are inconvertible types.

I can't find anything in the previous two chapters to help me solve this. it actually says in chapter 2 boolean and int are not compatible. The author of this book is mocking me! So I need someone to give me a hint and point me in the right direction. Is it possible to solve this problem by casting incompatible types or are my barking up the wrong tree? Should I be trying if statements instead? Something like if(true)System.out.print(1). I just want a hint, not a complete answer. Thanks for taking the time to help me!

Re: Beginners Problem Boolean to Int?

Originally Posted by DarrylBurke

You're very very close; have you learned how to use else in conjunction with if?

db

Thank you for your quick reply, I know about if{}else{} but that isn't covered until Chapter 3 so I thought this must not be the solution the author is looking for since this question is asked in chapter 2. Is it possible to do it with the if statement alone? The if statement was covered in chapter 1 so this might be what the author is looking for?