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 trialSheree Taylor
538 PointsDo while loop exercise 2 of 3. Error yet I am not getting any preview results.
String response = "true"; boolean isNo; console.readLine("Do you understand do while loops? "); do { isNo = response.equals("No"); if (isNo) { console.readLine("Try again. "); } }
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = "true";
boolean isNo;
console.readLine("Do you understand do while loops? ");
do {
isNo = response.equals("No");
if (isNo) {
console.readLine("Try again. ");
}
} while(isNo);
1 Answer
Malcom T.L Musuma
11,363 PointsString response = console.readLine("Do you understand do while loops? "); do{ response = console.readLine("Do you understand do while loops? "); }while(response.equals("No"));
Hello, that worked for meπ. So you are required to prompt the user with a question(the 'do' part) as long as the response they typed in is No(the 'while' part)