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

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. :)