Data verification input in loop
<p>I have tried various techniques to check the values of user input in this method.  The user should only be able to enter a '1' or a '0'.  If any other input is used there should be an error message and the program exits.  Any ideas?  I got it to work for the first digit but not the second through the tenth.</p>

<pre><code>    System.out.println("Enter a ten digit binary number.  Press 'Enter' after each digit.  Only use one or zero. :");

        binary[0] = keyboard.nextInt();

        for (index = 1; index &lt; 10; index++)
            binary[index] = keyboard.nextInt();// fill array with 10 binary
                                                // digits from user. User
                                                // must press 'Enter' after
                                                // each digit.
</code></pre>
