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 trialPatrick Mitchell
Courses Plus Student 1,104 PointsUsing the console's printf method, display a message that says, "First name: ", followed by the first name that the user
I am confused on how to enter the last part of the question. "followed by the first name that the user has entered.
// I have imported java.io.Console for you. It is a variable called console.
String firstName = "Patrick";
console.readLine ("firstName");
String lastName = "Mitchell";
console.readLine ("lastName");
console.printf("firstName");
console.printf("%s\n , firstName");
1 Answer
ShadowCode.... ......
Courses Plus Student 725 PointsYou have multiple errors on your code first you are not storing the input from the user because you are only receiving input when your write console.readLine() but you are not storing that value you must store the value in a variable like this -> String firstName = console.readLine("please enter your first name");
The second error is you are entering the parameters incorrectly, visit the code below I have provided to see the difference.
String firstName = console.readLine("enter your first name");
String lastName = console.readLine("enter your last name");
console.printf("%s", firstName);
console.printf("%s", lastName);