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 trialfrank colin
10,488 Pointsi need help with this Print out to the screen using the printf method on console, "Last name: " and the user's last nam
can you show me an example of how this should look?
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("First name");
String lastName = console.readLine("Last name");
console.printf("First name %s\n", firstName);
console.printf("%s first name\n", firstName);
console.printf("Last Name %s\n", lastName);
console.printf("%s Last Name\n", lastName);
1 Answer
Chase Marchione
155,055 PointsHi Frank,
You have a couple extra printf method calls/statements in there. Let's just keep the ones that print the way the challenge wants us to: by printing out "First name" and then the contents of the firstName variable, and "Last name" and then the contents of the lastName variable. I also recommend using actual names: this challenge wants us to imagine the printout as being like a form in which it asks for the person's first and last name, and a person inputs their own first and last names.
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("Bob");
String lastName = console.readLine("Saget");
console.printf("First name %s\n", firstName);
console.printf("Last name %s\n", lastName);
Hope this helps!
frank colin
10,488 Pointsfrank colin
10,488 PointsThis covers my question with great detail. Thank you CJ.