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 trialFabio Caceres
Courses Plus Student 1,241 Pointswhat does this error question mean "Did you use console.printf and to write out the formatted string with the response?
in the Java track I received this error, it feels that this was not covered, is the word in the error message a boolean operater?
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean isInvalidResponse;
do{
response = console.readLine("Do you understand do while loops? ");
isInvalidResponse=(response.equalsIgnoreCase("no")); {
console.printf("Because you said <response>,you passed the test!");
}
}while(isInvalidResponse);
1 Answer
Dan Johnson
40,533 PointsWhere it says "response" it wants a placeholder that you will swap out with the contents of response. Use something like this for the format string:
"Because you said %s, you passed the test!"
And then pass in response to printf with it.
Edit: Fixed a formatting issue. The empty string was suppose to be "response".
Fabio Caceres
Courses Plus Student 1,241 PointsFabio Caceres
Courses Plus Student 1,241 PointsDan, Thank you for your response, however, how can I possibly understand that the "Did you use console.printf and to write out the formatted string with the response" to mean "it wants a placeholder that you will swap out with the contents of response. " I also do not understand your sentence "And then pass in response to printf with it." Can you or someone break down the part of the error message that says what it says? I do not feel I am learning the why of my mistake and the verbage of the questions is confusing. Are the other questions like this, I spent too much time last night trying to interpret the meaning of the question, time I could have spent doing other lessons. How do I read these vague questions and error messages?
Dan Johnson
40,533 PointsDan Johnson
40,533 Points%s is a placeholder that is expected to be replaced by a
String
with printf or some other formatting method:console.printf("%s %s %s", "First", "Second", "Third");
You supply the extra arguments in the order you want them to be replaced. The above code would produce this output:
First Second Third