Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java

Paul Zutrau
Paul Zutrau
2,537 Points

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.

Paul Zutrau
Paul Zutrau
2,537 Points

I forgot the " after Try again.

Paul Zutrau
Paul Zutrau
2,537 Points

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

1 Answer

Steven Parker
Steven Parker
216,012 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.