Check how many digits in Java program & and terminate if not 5 digits? : <p>I am trying to complete an assignment, and I have almost fully completed it but I am have some trouble figuring out the last part. </p>

<p>How to: Check whether the number you received has five digits or not. Terminate gracefully if it doesn’t by notifying that the number should have 5 digits.</p>

<p>I've tried some stuff but I cannot get it to check correctly.</p>

<p>Here is my code:</p>

<pre><code>import java.util.Scanner;

public class Five
{
  public static void main( String args[] )
{
    Scanner input = new Scanner( System.in );

    int number;
    int digit1;
    int digit2;
    int digit3;
    int digit4;
    int digit5;

    System.out.print( "Enter a five digit integer: " );
    number = input.nextInt();

    digit1 = number / 10000;
    digit2 = number % 10000 / 1000;
    digit3 = number % 10000 % 1000 / 100;
    digit4 = number % 10000 % 1000 % 100 / 10;
    digit5 = number % 10000 % 1000 % 100 % 10;

    System.out.printf( "Digits in %d are %d %d %d %d %d/n",
        number, digit1, digit2, digit3, digit4, digit5 );

   }
}
</code></pre>

<hr>

<p>Thank you</p>
