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 Java Basics Perfecting the Prototype Looping until the value passes

Mehtab Kayani
Mehtab Kayani
3,179 Points

I have done all the things that are required but it not working. What am I missing?

Can you please let me know.

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
Boolean isValid;
do{
  response = console.readLine("Do you understand do while loops?");
  isValid= (response.equalsIgnoreCase("no"));

}while(isValid);
console.printf("Because you said" +response+ ",you passed the test!");

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Mehtab Kayani ! You're super close here but you haven't quite fulfilled all the requirements. I will say that your loop is spot on as is your logic! But in the last step, it specifically asks for a formatted string. But you used a concatenated string. Also, in your concatenated string you forgot a space before the response, but that's not really the issue here. These are both valid ways to print a string, but Treehouse has an obligation to make sure you know how to use multiple methods to achieve similar results.

You wrote:

console.printf("Because you said" +response+ ",you passed the test!");

But they were expecting this version:

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

The latter is a "formatted" string because it replaces the %s token with the value stored in the response variable.

Hope this helps! :sparkles:

Mehtab Kayani
Mehtab Kayani
3,179 Points

Hi Jennifer, Thank you for your help. I got it right now. :)