Salem Osi1,928 Points
No idea what I'm doing wrong
I'm pretty sure I got everything right, but it's still giving me syntax errors, does anybody know what I'm doing wrong?
// I have imported java.io.Console for you. It is a variable called console. String firstName = "Tyrone"; console.readLine (firstName); String lastName = "West"; console.readLine (lastName); console.printf ("First name:%s", firstName);
Tonnie FanadezUX Design Techdegree Graduate 22,772 Points
Hi Salem Osi
Thanks for your question.
String firstName = "Tyrone";
Your first line of code is declaring a String and forcing it to be "Tyrone" which should not be the case. Remember the challenge requires you to collect input from the user and not to set a String to a value.
The way to get input from the user is to use the console's method readLine() to prompt for the name. readLine method takes in the message which will prompt the user.T he code goes like this:
//getting feedback from the user using console.readLine() method String firstName =console.readLine ("what is your first name?"); String lastName =console.readLine ("what is your first name?");
When it comes to print out the info you can use the console's printf method as per the below code:
console.printf("First name: %s", firstName); console.printf("Last name: %s", lastName);