Leong Lee52 Points
I need help, I need to know what i am doing wrong it is asking for %s?
Need help with one of the challenges
String firstName = console.readLine("What is your first name? "); String lastName = console.readLine("What is your last name? "); console.printf("First name:", firstName);
Faraz Malik5,756 Points
You're supposed to place a %s at the last line to give a reference for where you are going to input the variable. The statement for printing out was also incorrect. It's like this:
System.out.printf("Firstname: %s", firstName);
Eric Queen10,212 Points
Hello Leong, Seems like you forgot something, the %s. That is why it is prompting you for it. The printf() method takes in an argument, which you have by the way of "firstName". Because firstName is of String type you need to tell printf() where in the output string you want it to be placed with the %s. Your code should look like this:
String firstName = console.readLine("What is your first name? "); String lastName = console.readLine("What is your last name? "); console.printf("First name: %s %n", firstName);
I have also added the %n to tell the console to move to a new line after it finishes printing the text. Otherwise your prompt will be on the same line after the firstName.
Hope this helps and good luck!