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 trialDaniel Monroe
305 PointsDid you use console.printf and to write out the formatted string with the response???? Why isn't this working?
Been going crazy trying to figure this out. Everything is layed out perfectly as far as I can see. Please help
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean invalidAnswer;
boolean correctAnswer;
do {
response = console.readLine("Do you understand do while loops? ");
invalidAnswer = (response.equalsIgnoreCase("No"));
correctAnswer = (response.equalsIgnoreCase("Yes"));
if (invalidAnswer) {
console.printf("Please enter correct response\n");
}
if (correctAnswer) {
console.printf("Because you said s%, you passed the test!", response);
}
} while(response.equalsIgnoreCase("No"));
1 Answer
Rimaz Rizlan
1,393 Pointsbro you have made it complicated.. try this..
String response;
do{ response = console.readLine("Do you understand do while loops?");
}while(response.equalsIgnoreCase("no"));
console.printf("Bcause you said %s, you passed the test!", response);