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

Dean Cooper
Dean Cooper
463 Points

I have no idea what the question is asking me. It is so vague. Please be more specific.

The final question of this module asks to use a console.printf. nothing specific. what do they mean?

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

1 Answer

Simon Coates
Simon Coates
28,694 Points

Your code is needlessly complex, i think. Maybe try:

String response = null;
do {
response = console.readLine("Do you understand do while loops  ");
} while (response.equals("No"));
console.printf("Because you said %s, you passed the test!", response);

When your response is valid, it will jump outside the do block. Hence you can just put the console print outside. Additionally, it wants you to use a placeholder with the printf.