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 trialgerald greene
598 PointsUsing the console's printf method, display a message that says, "First name: ", followed by the first name that the user
not sure why it is not accepting the code for this question in console? code looks exact same as previous lesson and workspace
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine ("what is your name? ");
String lastName = console.readLine ("what is your last name? ");
console.printf("my name is %s\n", firstName);
6 Answers
Steve Hunter
57,712 PointsHI Gerald,
It is expecting the output to look a certain way -that's the test the compiler is looking to pass. So, the string output should look like "First name: ....", as the question says So your code should look more like:
String firstName = console.readLine("Enter your first name: ");
String lastName = console.readLine("Enter your last name: ");
console.printf("First name: %s", firstName);
Hope that helps,
Steve.
Jaro Schwab
8,957 PointsYou need to output the following: First Name: your variable.. So your code should look 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);
console.printf("Last name: %s", lastName);
maria salas
54 Pointsconsole.printf("First name: %s", firstName); console.printf("Last name: %s", lastName);
Ary de Oliveira
28,298 Points//
String firstName = console.readLine("Ary"); String lastName = console.readLine("de Oliveira"); console.printf("First name: %s", firstName); console.printf("last name %s",lastName);
fazal pasha
216 PointsBummer! Ensure your format string contains the required text "First name:"
.
Steve Hunter
57,712 PointsHi Fazal,
Did you get this sorted or do you still need some assistance? Here to help!
Steve.
gerald greene
598 Pointsoh great, thanks very much for the super fast reply steve, greatly appreciated :)
Ger
Steve Hunter
57,712 PointsNo problem!
The challenges are quite specific as to what they expect.
Glad you got it sorted. :-)
Steve.