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 trialPhilip Schultz
11,437 PointsI am asked to make a simple do while loop that ask's the user a question. If the answer is no then repeat.
please help i don't see why the code is not working.
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean wrong;
do {
response = console.readLine("Do you understand do while loops?");
wrong=response.equalsIgnoreCase("no");
if (wrong) {
console.printf("This will repeat untill answer is yes");
}
while (wrong);
}
1 Answer
Amy Tucker
13,273 PointsIt looks like your closing brackets are a bit off. The last closing bracket should come before the while(wrong) statement instead of after.
do {
} while (wrong);
Amy Tucker
13,273 PointsAmy Tucker
13,273 PointsThat didn't format quite the way I thought it would but I hope that makes sense :)
Philip Schultz
11,437 PointsPhilip Schultz
11,437 Pointsyup that was it. Thank you Amy.