How to use Scanner and conditions in Java?
<p>I'm fairly new to java and now I'm testing the <code>Scanner</code>! Here is my code:</p>

<pre><code>package Examples;

import java.util.Scanner;

public class UserLogin
{
    public static void main(String[] args)
    {
        Scanner in= new Scanner (System.in);
        System.out.println("Please enter your name!");
        String keyboard= in.nextLine();    

        System.out.println("Welcome: " + keyboard);
        System.out.println("What is your password?");

        Scanner x= new Scanner (System.in);
        int password= x.nextInt();


        if(password ==14567) 
        {
            System.out.println("Password accepted ! you are welcome!");
        }
        else
        {
            System.out.println("Sorry wrong password! Try again");
            Scanner input = new Scanner(System.in);
            int password2=input.nextInt();
            while (password2==password);
            {
                System.out.println("Welcome!!!!");
            }   
        }
    }   
}        
</code></pre>

<p>I want the user's name, password and that is it! But I noticed that when I ask the name even if I press the enter key, it will ask me the password right away. So I want to make sure I get a name.  Also when I ask the password I want to be able to give him few chances before saying goodbye.</p>

<pre><code>Please enter your name!
michel
Welcome: michel
What is your password?
12345
Sorry wrong password! Try again
12345
</code></pre>

<p>This is what I get on the console.</p>

<p>Thanks!</p>