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 trialaman JAIN
416 Pointsi am not getting tis question kindly help
hi there it would be very nice of you if you can guide me in this problem
2 Answers
Katie Wood
19,141 PointsHi there,
Let's go through step by step. First, it asks you to create a String variable called response, based on the user's response to "Do you understand do while loops?" - that looks like this:
String response = console.readLine("Do you understand do while loops? ");
That's Step 1. Next, it asks you to create a do-while loop that will continue until the user answers something other than "No". So, we want to do the prompt we just made over and over as long as the answer is "No". So first, we want to move the prompt inside the do-while loop:
do {
String response = console.readLine("Do you understand do while loops? ");
} while ();
Now, the challenge reminds us that we want to initialize response outside of the loop (otherwise, it will create a new variable every time) - so, we can do this:
String response = "";
do {
response = console.readLine("Do you understand do while loops? ");
} while ();
Now we just need the 'while' condition - we know that we want it to repeat while the answer is "No", so:
String response = "";
do {
response = console.readLine("Do you understand do while loops? ");
} while (response == "No");
That's it for Step 2. See if you can get Step 3 - you'll need console.printf.
Good luck!
aman JAIN
416 Pointsthanks i really appreciate your help