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 trialK W
3,736 PointsOutput a sentence that takes both the noun and past tense verb using a single statement. It should look like this: name
Output a sentence that takes both the noun and past tense verb using a single statement. It should look like this: name really past tense verb this coding exercise.
this challenge makes no sense to me any help would be appreciated. console.printf("%s what do you want from me %s");
5 Answers
Gloria Dwomoh
13,116 PointsIt tells you to output a sentence that looks like this "name really past tense verb this coding exercise."
haha you have almost done what it wants in your joke XD
console.printf("%s really %s this coding exercise.", /*here add the variables needed*/);
Leo Berisha
438 Pointsconsole.printf(" %s really %s described above", name, pastTenseVerb);
This gone work !
Alwin Joy
1,143 Pointstnx it worked
K W
3,736 Pointsnevermind passed with String name = console.readLine("kris"); String pastTenseVerb = console.readLine("hated"); console.printf(%s really %s, name, pastTenseVerb);
Gloria Dwomoh
13,116 PointsYes the major issue what as I wrote earlier it was expecting you to write "%s really %s this coding exercise." or at least the "%s" after "really" while you had written "%s really this coding exercise %s". I'm glad it works now.
Ho Sun Lee
2,003 PointsNoice, I just did this as well, and was trying to post something on here to help out, but it seems you already got it.
Rui Bi
29,853 PointsThe printf() method can take multiple parameters/arguments for variables.
You can insert multiple %s in your format String, followed by multiple variables that you would like to be included. The number of %s must match the number of parameters following the format String. For example, if you wanted two variables to be printed in one printf(), use the following pattern:
String noun= "Java"
String adj= "fun"
console.printf("%s was very %s", noun, adj);
The output would be: "Java was very fun"
You can use any number of %s and arguments. Just the main things are: the order the arguments appear in your output is the same as the order the %s appear, and the number of arguments must equal the number of %s.
If instead you had:
console.printf("%s was very %s", adj, noun);
The output would be: "fun was very Java"
K W
3,736 Pointsthank you that makes so much more sense but my entry still won't pass the code challenge any other suggestions?
String name = console.readLine("kris"); String pastTenseVerb = console.readLine("hated"); console.printf("%s really this coding exercise %s", name, pastTenseVerb );
Gloria Dwomoh
13,116 PointsWhat you have written gives output "name really this coding exercise pastTenseVerb" and that is not what it is asking. What it wants is... "name really past tense verb this coding exercise."
hint: Watch where you position the '%s'