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 trialayub ali
Courses Plus Student 723 Pointsanyone can help me with this i will appreciate
this quiz
// 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");
String realy=console.readLine("realy");
console.printf("%s",name);
console.printf("%s",pastTenseVerb);
console.printf("%s",realy);
1 Answer
Steve Hunter
57,712 PointsHi there,
The first two lines are prompting the user to enter a name then a past tense verb and storing that input in the two named variables. Something like:
String name = console.readLine("Enter your/a name: ");
String pastTenseVerb = console.readLine("Enter a past tense verb: ");
After that, you want to output a string using what the user just entered, which is stored in your two variables. To do this, you use the %s
placeholder where you want to insert the contents of that variable. You can do this multiple times - but you must pass in the right number of variables after the string to fill all the placeholders.
The string is "<name> really <ptverb> this coding exercise"
. So, instead of the two variables, switch those for %s
. Then, after the string, pass in name
first, then pastTenseVerb
. That looks like:
console.printf("%s really %s this coding exercise", name, pastTenseVerb);
I hope that makes sense.
Steve.