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 trialSonam Shaikh
3,529 PointsUsing the console's printf method, display a message that says, "First name: ", followed by the first name that the user
error
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("what is your name? ");
console.printf = ("first name:");
String lastName = console.readLine("ehat is your last name? ");
2 Answers
joelearner
54,915 PointsHi Sonam,
The order of your statements might be causing an issue with the feedback in the system. When I reordered your code, I received this error: "Bummer: Ensure you put the string formatter %s
in your format string". So to correct this, insert the %s in your printf statement. Your code should look something like this:
String firstName = console.readLine("What is your name? ");
String lastName = console.readLine("What is your last name? ");
console.printf("First Name: %s", firstName);
Cheers!
Yamil Pérez
Courses Plus Student 2,054 PointsString firstName = console.readLine("What is your first name"); String lastName = console.readLine("whta is your last name"); console.printf("First name: %s", firstName); console.printf("Last name: %s", LastName);
Yamil Pérez
Courses Plus Student 2,054 PointsYamil Pérez
Courses Plus Student 2,054 Pointsyou are not display the first name. you only are displaying the message .so you code should look this String firstName = console.readLine("what is your name? "); console.printf = ("first name: %s", firstName); String lastName = console.readLine("ehat is your last name? "); Same for the lastName