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 trialmilly mines
339 Pointswhat am I missing?
I cant figure out whats wrong
// I have initialized a java.io.Console for you. It is in a variable named console.
String response ;
do {
response =console.readLine("Do you understand do while loops");
if(response.equals ("No"))
console.printf("Do you understand do while loops");
}while (response.equals ("No"));
console.printf("Because you said No, you passed the test!");
2 Answers
Steve Hunter
57,712 PointsHi Milly,
Your loop is mainly correct; it does the job. But you can delete the if
statement in there as wellas the second question prompt; the printf
isn't needed as your readLine
does that for you.
Outside of the loop, the challenge wants an output that uses printf
to insert the contents of response
into the string. The output should be, "Because you said Yes, you passed the test!", or something like that.
So, insert a %s
placeholder within the output string and use the format, printf("some text %s some text", response);
to insert the right value in there.
I hope that helps,
Steve.
Steve Hunter
57,712 PointsHi Milly,
I added some somments in your code. You've pretty much got that task nailed! Good work.
You should end up with this:
String response;
do{
response = console.readLine("Do you understand while loops?: ");
} while(response.equals("No"));
console.printf("Because you said %s, you passed the test!", response);
Steve.
milly mines
339 Pointsthank you so much :)
Steve Hunter
57,712 PointsNo problem!
milly mines
339 Pointsmilly mines
339 Pointsit didn't work
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsCan you post your code please?
milly mines
339 Pointsmilly mines
339 Points