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 trialBrian Pedigo
26,783 PointsWhat is wrong with this code?
This should work, I am missing something. But for what ever reason I cant pass the code challenge with it. Any ideas?
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = "yes";
do{
response = console.readLine("Do you understand do while loops?");
} while(response.equalsIngoreCase("yes"));
3 Answers
Ken Alger
Treehouse TeacherBrian;
Welcome to Treehouse!
A couple of things.
- We want to loop while our response is No, not while it is Yes.
- You have a syntax error in your
equalsIgnoreCase()
method. Check your spelling of the function.
Post back if you are still stuck, and happy coding.
Ken
Seth Kroger
56,413 PointsLooking over the challenge I see you're being asked to continue looping while the input is "no" not "yes". Fix that and you should be good to go.
Michael Hess
24,512 PointsHi Brian,
The challenge can be completed as follows:
// I have initialized a java.io.Console for you. It is in a variable named console.
String response; //Declare response as String variable
do
response = console.readLine("Do you understand do while loops?"); //yes or no saved to response variable
while(response.equalsIgnoreCase("no")); // Repeat loop if response is "no"
//This is task 3
console.printf("Because you said %s you passed the test!", response);
Hope this helps! If you're still having issues we're here to help!