// Ask user for name, // then greet that person. // Obtain input with the Scanner class. // Show output with printf method. import java.util.Scanner; public class Greeter2 { public static void main(String[] args) { // Create Scanner object. Scanner console = new Scanner(System.in); // Declare name. String name; // Display prompt. System.out.print("Enter your name: "); // Input name. name = console.next( ); // Show message box with greeting. System.out.printf("Hello, %s.", name); } } // Prompt on console: Enter your name: // Sample input to keyboard: Bob // Output message to console: Hello, Bob.