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
chibuzor Iheaka
277 PointsJava track Challenge task 3 of 4 not working.
I am working on the Java basic track and tried to answer number 3 challenger where the following is asked, "Using the console's printf method, display a message that says, "First name: ", followed by the first name that the user has entered." You can see what I typed below:
// I have imported java.io.Console for you. It is a variable called console.
String firstName = "Alex";
String lastName = "Iheaka";
console.readLine(firstName);
console.readLine(lastName);
console.printf("First name: %s %n", firstName);
I am getting the following error: " Bummer! Did you forget to pass the firstName parameter to the printf function?"
What is going wrong please?
1 Answer
Steve Hunter
57,712 PointsHi there,
You're nearly there with this. You want to declare a String variable and then assign into it the result of the readLine() method. Use the parentheses of the readLine method to prompt the user with an output string.
For example, this can look like:
String myName = console.readLine("What is your name?: ");
After that, you need to output the received string - you have done that correctly. The challenge is complaining that the input isn't working because you have hard-coded the contents of firstName and lastName so the tests aren't passing.
I hope that helps - let me know how you get on.
Steve.
Ben Reynolds
35,170 PointsBen Reynolds
35,170 PointsCan you post a link to the challenge? I thought I found it but the one I see has 3 parts, not 4.