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 trial

Java Java Basics Getting Started with Java IO

i am struggling on java basics challenge task 1-4 specifically on 4.

Challenge Task 4 of 4

Using the console's printf method, display a message that says, "Last name: " followed by the last name that the user has entered

step 4. console.printf("Last Name: ", last Name) console.printf("%s, lastName");

i did the same for the 3rd step which required to do the same but only the first name and it worked but doesn't work for this step can someone help?????

IO.java
// I have imported java.io.Console for you.  It is a variable called consolec
String firstName = console.readLine("firstName");
String lastName = console.readLine("lastName");
console.printf("First Name: ", firstName);
console.printf("%s", firstName);
console.printf("Last Name:", lastName);
console.printf("%s", lastName);

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Ivan! You're doing well, but I'm not really sure why this is passing step 3. The %s token should be on the same line with the the the display messages. Also, note that challenges can be very strict and will sometimes or even most often want output that is the same as what they're expecting to the letter. This includes punctuation, capitalization and even spacing. In your printf statements you've capitalized the "N" in "Name", but the challenge asks for "name". Also, there should be a space after the colon and before the name is printed. Here's what the last name print out will look like and you'll need to adjust your other print out of the first name to match.

// Note the lower case "n" in "name, the addition of the token, and the space after the colon
console.printf("Last name: %s", lastName);

Hope this helps! :sparkles:

Thank you for helping me get through this challenge, very much appreciated. :)