Java Java Basics Getting Started with Java IO

Using the console's printf method, display a message that says, "First name: ", followed by the first name that the user

How do i need to method
// I have imported for you.  It is a variable called console.

String firstName = "ben";
String lastName = "tom";
console.readLine("what is your fistName: " + firstName);
console.readLine("what is your lastName: " + lastName);

1 Answer

You need to prompt user for first name and last name. Store those in variables firstName, lastName like so:

String firstName = console.readLine("What is your first name?");
String lastName = console.readLine("What is your last name?");

Now lets show message to the screen:

console.printf("First name: %s", firstName);