Java Java Basics Perfecting the Prototype Conditional ints

Quinn Alexander
Quinn Alexander
401 Points

getting "Are you sure you called `console.printf` in the code block within your if statement body?" and not printing

I feel like i have followed the tutorial and am still not getting a print and getting this error. part 1 was fine but this part isnt working

Conditional.java
int numberOfPeople = 3;
if (4 < numberOfPeople){
  console.printf("your table is ready");
}

1 Answer

Michael Hulet
MOD
Michael Hulet
Treehouse Moderator 47,709 Points

Your logic here is backwards. Your if condition is sorta backwards, which developers often call "Yoda casing". If you reverse it, the reason why your code doesn't pass may become a bit more clear:

int numberOfPeople = 3;
if (numberOfPeople > 4){
  console.printf("your table is ready");
}

The question asks you to print that string if numberOfPeople is less than 4, but your code only does it if numberOfPeople is greater than 4. If you flip the logic to compare it the other way, your code should pass the challenge. Great job! Also, don't forget to capitalize the Y