import java.util.Scanner;

/**
 * Simple illustration of an issue when using Scanner.nextLine().
 * @author Hyrum D. Carroll
 * @version 0.1 (January 27, 2022)
 */

public class NextLineIssues_02{
    public static void main( String[] args ){
        int age = -1;
        String name = "";
        Scanner keyboard = new Scanner( System.in );

        //Input: 99\nDr. C\n
        System.out.print("Please enter your age: " );
        age = keyboard.nextInt();
        //Input: \nDr. C\n
        System.out.println( "You entered: " + age);

        keyboard.nextLine(); // ignores the newline leftover from the call to nextInt
        //Input: Dr. C\n

        System.out.print("Please enter your first and last name: " );
        name = keyboard.nextLine();
        //Input: \n
        System.out.println( "You entered: \"" + name + "\"");

    }
}