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
Lyric Abbott
35,595 Pointshelp
Print out to the screen using the printf method on console, "Last name: " and the user's last name.
my code:
String firstName = console.readLine("What is your name? ");
String lastName = console.readLine("What is your name? ");
console.printf(lastName);
console.readLine("What is your first name?: ", firstName);
console.readLine("What is your last name?: ", lastName);
http://teamtreehouse.com/library/java-basics/getting-started-with-java/io
3 Answers
Ken Alger
Treehouse TeacherLyric;
Your last two lines of code aren't printing anything, they are looking for input.
console.readLine is for input, correct?
Ken
Gloria Dwomoh
13,116 PointsKen is right. Also try to remember using printf along with placeholders like "%s," to do what it asks you.
Ken Alger
Treehouse TeacherLyric;
Sorry about the lack of verbosity in my last post. I was posting from my iPhone whilst removing dry-rot from under a house and wanted to at least get you started in the correct direction.
So, if you have gotten through Tasks 1 & 2 you have collected information from the user and stored their first name in the firstName string variable and their last name in the lastName variable. That was the first two lines of code, which look great!
Tasks 3 & 4 ask us to print out to the screen using the printf method on console, "First name: " and "Last name: " and the user's first and last names, respectively. It looks like in your code something has been changed since Task 3, because I don't see where it would meet the requirements to print out the firstName variable after the challenge prompt of "First name: ".
If you remember back to the previous code challenge for this course Strings, Variables, and Formatting we are asked to print to the console in Task 3 using the string formatter (%s). Tasks 3 & 4 of this challenge are extremely similar to that in terms of syntax. This challenge has built upon the last one (funny how that works) and instead of us setting the value for firstName we are allowing the user to input it. The output has changed slightly, but the code to do so is predominantly the same.
Post back if you need additional assistance.
Ken
Dave McFarland
Treehouse TeacherDave McFarland
Treehouse TeacherHi Lyric
To put code into a forum post use triple back ticks -- ``` — around the code. I fixed your code here, but in the future here's a forum discussion that describes how to add HTML, CSS, JavaScript or other code to the forum: https://teamtreehouse.com/forum/posting-code-to-the-forum