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 trial

Java Java Basics Perfecting the Prototype Looping until the value passes

aniket roy barman5
aniket roy barman5
4,390 Points

Bummer! Did you use console.printf and to write out the formatted string with the response?

don't know where is the mistake....need help

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean isInvalidWord;
  do{
 response = console.readLine("Do you understand do while loops?");
    isInvalidWord = (response.equalsIgnoreCase("no"));
    if (isInvalidWord)
    {
    console.printf("Because you said no <response> , you passed the test!\n");
  }
  }while(isInvalidWord);

2 Answers

Looks to be a format issue, meaning your string simply isn't matching what treehouse's automated testing was expecting.

try to change the following line as such:

console.printf("Because you said no, you passed the test!\n");

Remember when you do these challenges, the output must match exactly to what is expected. If you remove the <response> from your String, your code will the automated testing.

aniket roy barman5
aniket roy barman5
4,390 Points

Got the answer.....since <response> is a string variable, i can't put <response> directly ,so i need to indicate it as '%s'

console.printf("Because you said no %s , you passed the test!\n");