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 trialLogan Detering
1,953 PointsLost, please help
Im really confused, can someone help?
// I have initialized a java.io.Console for you. It is in a variable named console.
String verb;
boolean isResponse;
do{
verb = console.printf("Do you understand while loops");
}
1 Answer
Grigorij Schleifer
10,365 PointsHI Logan,
I modified and commented your code a little bit:
String response = "";
// the String variable must be named response
// and donΒ΄t forget to initialize it to " "
boolean isResponse;
// default value of the boolean is false
do{
response = console.readLine("Do you understand while loops");
// assign the input from user to the "response"
isResponse = response.equalsIgnoreCase("No");
// check if the input is "No"
// then the boolean is true
}while(isResponse);
// while the boolean is true == Users input is No
// repeat the code inside the loop
console.printf("Because you said%s, you passed the test!", response);
// print the response out using String formatter %s
Grigorij