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 trialJames Young
775 Pointsoutputting multiple variables
hey guys please if anyone could take a look at my code and let me know where I am messing up I would really appreciate it. Thank you
// I've imported java.io.Console for you. It is stored in a variable called console for you.
String name = console.readLine("Name");
String pastTenseVerb = console.readLine("Past tense verb:");
console.printf("name: %s",name) really ("Past tense verb: %s",pastTenseVerb) this coding exercise.
2 Answers
Richard Ling
8,522 PointsHi James,
The question asks for the output to look like this: name really past tense verb this coding exercise.
I can see how this may be confusing, but it's actually asking for: name really past tense verb this coding exercise. Where the bold items are the variables that you have populated from the user.
The last line should then look like this:
console.printf("%s really %s this coding exercise.", name, pastTenseVerb);
You can write the output string within the quotes, just putting %s in the places that you want your variables to appear, and then comma separate them afterwards. So the first parameter name will replace the first %s and the second parameter pastTenseVerb will replace the second %s.
I hope this makes sense :)
Thanks, Rich
James Young
775 PointsHey Rich,
Thank you again for helping me out, it is a little confusing starting out. But having people like you, who help out when can, really makes learning this stuff a little simpler. Thank you for your time!
Best Wishes
Richard Ling
8,522 PointsNo problem James, I'm new to Treehouse, and to a couple of the technologies here too, but it's always good when there's an active community to try help us all along when we need it ;)
Good luck with the rest of the courses!