Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjoseph bonsignore
779 Pointsjava basics : your table is ready
I'm on challenge to of conditional ints and I don't understand it. Can someone explain how to do it?
1 Answer
Steve Hunter
57,712 PointsHi Joseph,
First you need to create a variable (an integer) called number of people (camel case) that holds a value of three. Start with the int
keyword to make the variable of the integer datatype, then join number of people together, capitalsing each initial except the first one, like numberOfPeople
. That looks like:
int numberOfPeople = 3;
Then you need to test numberOfPeople
to see if
it is less than 4. If it is, write out "Your table is ready". Use an if
statement and compare numberOfPeople
to 4 using the less than operator. Then use console.printf("")
to output the string.
int numberOfPeople = 3;
if(numberOfPeople < 4){
console.printf("Your table is ready");
}
Make sense?
Steve.