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 trialnygle gillett
Courses Plus Student 340 PointsI'm new to this can someone help me understand what I'm doing wrong.
Using the console's printf method, display a message that says, "Last name: " followed by the last name that the user has entered.
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("Nygle");
String lastName = console.readLine("Gillett");
console.printf("Hello, My Name Is %s\n", firstName);
console.printf("%s is learning how to wrte java\n", firstName);
console.printf("First name");
console.printf("Last name %s", lastName);
3 Answers
Steven Parker
231,269 PointsThe instructions say to print "Last name: " (with a colon) but you don't have a colon.
But more than that, you have a lot of extra print statements that were not asked for by the challenge, and you'e missing the one that task 3 asked for. Did you have one before and remove or change it?
And the readLline function doesn't take an argument (but I guess the challenge didn't catch that).
Sławomir Lasik
7,792 PointsIn the challanges write the minimum that is required. Couse when You write more the grading system prints out difficult to understand answers.
But to the point.
This is what your program runs:
Nygletest1
Gilletttest2
Hello, My Name Is test1
test1 is learning how to wrte java
First nameLast name test2
I wrote in cosole test1 after Nygle and test2 after Gillet.
I think You can see the problem by yourself now. If not. Go through videos one more time, couse I think you might do not understand it correctly.
nygle gillett
Courses Plus Student 340 Pointsthank you that did help me understand the problem I also saw the extra lines I had in there I appreciate your help
nygle gillett
Courses Plus Student 340 Pointsnygle gillett
Courses Plus Student 340 PointsThe third question said. Using the console's printf method, display a message that says, "First name: ", followed by the first name that the user has entered.
I added the colon to the line but I'm still getting it incorrect saying. Did you forget to pass the
lastName
parameter to the printf function?Steven Parker
231,269 PointsSteven Parker
231,269 PointsTask 3 is about the first name. And it wants you to show "First name: ", but you have "Hello, My Name Is " instead.
Task 4 is about the last name, and it wants to see "Last name: " (with a colon).
You will need to fix both of these, and remove the other lines that the challenge did not ask for.