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 trialBarisan Firildak
403 PointsI can't figure out what I need to do
I didnt understand the question
// 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?");
do {
String response =console.readLine("no");
1 Answer
Mihai Craciun
13,520 PointsOk, so the first task ask you to prompt the user with question "Do you understand do while loops?" and store it in the variable response. The code should look like this:
String response;
response = console.readLine("Do you understand do while loops?");
The second task ask you to put the prompt in a do...while loop that ask the user that question as long as the response is still 'No' (and don't forget to initiate the response as an empty String). The code should look like this:
String response = "";
do{
response = console.readLine("Do you understand do while loops?");
}while(response == "No");
The last task ask you to use the printf method that says "Because you said <response>, you passed the test!". The final code should look like this:
String response = "";
do{
response = console.readLine("Do you understand do while loops?");
}while(response == "No");
console.printf("Because you said %s, you passed the test!", response);
If you still don't understand how do...while loops work I strongly recommend you to review the last videos.