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 trialGeovani Estacio
Courses Plus Student 1,875 PointsHow do I continually prompt the user in a do while loop. I been stuck on this challenge for two week's now, please help.
I been stuck on this, what am I missing or doing wrong? I've tried everything that was shown by Craig on the video.
// 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("keep trying \n\n");
}
} while(response.equals("no");
2 Answers
jacobproffer
24,604 PointsHey Geovani,
The first thing you'll want to do is to end your String declaration with a semicolon. I've left a comment below as to where this should happen. Next, there is no need for an if statement with this challenge. You simply need to continuously prompt the user until the value returned is something other than "No". The last thing to pay attention to is your while condition. You are missing a closing parenthesis. Notice the difference between while(response.equals("No"); and while(response.equals("No"));
String response; // Remember the semicolon
do {
response = console.readLine("do you understand do while loops?");
} while(response.equals("No"));
Jenise Moody
Courses Plus Student 1,985 PointsI was stuck on this too. I was making it much harder than it needed to be. Thank you for posting this.
Geovani Estacio
Courses Plus Student 1,875 Pointsyour welcome =)
Geovani Estacio
Courses Plus Student 1,875 PointsGeovani Estacio
Courses Plus Student 1,875 PointsJacob, thank you for your help; you've help me get passed this challenge. you're a legend!!