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 trialChris Garavente
315 Pointshow to finish the do while loop exercise by saying you passed the test
Hi all,
I'm trying to figure out where I went wrong on the third part of this exercise and I can't figure out what I need to be inputting to get the results I want.
Thanks in advance for any help,
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = console.readLine("Do you understand do while loops? ");
boolean isInvalidWord;
do {
response = console.readLine("Do you understand do while loops? ");
isInvalidWord = (response.equalsIgnoreCase("no"));
if (isInvalidWord) {
console.printf("Do you understand do while loops? \n\n");
}
} while(isInvalidWord);
String correctresponse = console.readLine("Do you understand do while loops? ");
do {
response = console.readLine("Do you understand do while loops? ");
correctResponse = (response.equalsIgnoreCase("yes"));
if (correctResponse.equalsIgnoreCase("yes")); {
console.printf("Because you said yes, you passed the test! ");
}
} while(correctResponse);
1 Answer
Steven Parker
231,271 PointsThere should only be one loop for all tasks of this challenge. And there should only be one "readLine" call, from task 2 on it should be inside the loop.
The final message added in task 3 will go after the loop. Be sure to include the actual response given as part of the output string.
Chris Garavente
315 PointsChris Garavente
315 Pointsthanks so much for your response - really helped.