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 trialBeverly Banks
1,919 PointsNot sure what I am doing wrong. Java Basics Challenge task 3 of 3.
Have tried this different ways but can't seem to figure out what I am doing wrong. Thanks for your help!
// I've imported java.io.Console for you. It is stored in a variable called console for you.
String name = console.readLine ("Enter your name: ");
String pastTenseVerb = console.readLine ("pastTenseVerb: ");
console.printf( "Name, %s really, pastTenseVerb, %s this coding exercise" );
2 Answers
Paul Willis
4,082 Points// I've imported java.io.Console for you. It is stored in a variable called console for you.
String name;
String pastTenseVerb;
name = console.readLine("Please enter name:");
pastTenseVerb = console.readLine("Please enter a past tense verb: ");
console.printf("%s really %s this coding exercise", name, pastTenseVerb);
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 PointsHey Beverly,
the "print formatted" method takes a string which has placeholders like '%s' in it. For every placeholder you have to pass in an argument.
Here is an example:
String question = "How";
String name = "Beverly";
console.printf("%s are you %s?", question, name);
Two placeholders, two arguments.
Kind Regards, Florian
Beverly Banks
1,919 PointsThank you!
Beverly Banks
1,919 PointsBeverly Banks
1,919 PointsThanks!