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 trialEldin Jakubovic
319 PointsI have some problems with task 2. Help someone ?
i dont get it..
// I have initialized a java.io.Console for you. It is in a variable named console.
String response ;
boolean isInvalidWord;
do {
console.readLine("Do you understand do while loops?");
if (response.equalsIgnoreCase("No"));
if (isInvalidWord); {
console.printf("Try again");
}
} while(isInvalidWord);
2 Answers
Miguel Canas
Python Development Techdegree Student 11,470 PointsHey Eldin,
A couple of clues:
console.readLine("Do you understand do while loops?");
You are prompting the right question, but are you capturing the response here?
} while(isInvalidWord);
The goal of the task is to prompt the question and store the response. What do you need to test in order for this while loop to end?
Good luck!
~ Miguel
Wan Faruq Adiputra
2,938 PointsYou don't need to use a do-while loop.
naming the string:
String response;
prompting the questions:
console.printf("Do you understand do while loops?");
storing the result into the string response:
response = console.readLine();
or you can just combine prompting questions and storing the result:
response = console.readLine("Do you understand do while loops?");