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

I unable to answer the last question of java basics.

the question says: Finally, using console.prinf print out a formatted string that says "Because you said<response>, you passed the test!"
The correct code on the 1st 2 questions is the following: String response=console.readLine("Do you understand do while loops?"); boolean is InvalidWord; do{ response=console.readLine("Do you understand do while loops?"); isInvalidWord=(response.equalsIgnoreCase("no")); if(isInvalidWord){ console.printf("no. Try again. \n\n}; } }while(isInvalidWord)

I rewatched video several times and tried placing console.prinf different places in the code. I guess I am lacking basic understanding. any help would be appreciated.

I forgot the " after Try again.

thanks Steven, I'll clean up the code and add the console.printf at the end

1 Answer

Steven Parker
Steven Parker
229,644 Points

Besides the missing quote, there seem to be a few other issues:

  • the question should be asked only once, inside the loop
  • there should be no space in is InvalidWord
  • the symbol after ""no. Try again. \n\n" should be parentheses ) instead of brace }
  • the code to print out the "Because you said …" message still needs to be added at the end

For future questions, be sure to format any code and link the question to the course. Take a look at this video about Posting a Question, and perhaps also this one about sharing a snapshot of your workspace.