title: How to set integer value ranging from 1000 to 9999 in Java?
body: <p>This is my first time taking programming  class. This is also my first assignment, and I got stuck on how to set the input of number from users ranging from 1000 to 9999.</p>
  
  <p>My assignment is create a code that ask user to enter four digit integer, then display those individual number 3 spaces from each other (hint: use division and remainder arithmetic).
  I finally get it to print out each number 3 space away from each other.</p>
  
  <p>The problem is when my teacher says that a four digit integer are ranging from 1000-9999. So when I try to put 0001, it print out: 
  0   0   0   1</p>
  
  <p>And if I put 12345, it print out:
  12 3 4 5</p>
  
  <p>Is there anyway to do it?</p>
  
  <p>Thank you so much for help me out</p>
  
  <p>I can post a picture yet because im new to this forum.</p>
  
  <h2>anyway here is my code</h2>
  
  <pre><code>import java.util.Scanner;
  
  public class DigitsDemo
  {
  public static void main ( String[] args )
  {
      Scanner input = new Scanner ( System.in );
  
      System.out.print ( "Enter four digit numbers: " );//prompt the user to enter numbers
      int n = input.nextInt();//read number entered by user
  
      // determine the 5 digits
      int Digit1 = n / 1000;
      int Digit2 = n % 1000 / 100;
      int Digit3 = n % 1000 % 100 / 10;
      int Digit4 = n % 1000 % 100 % 10 / 1;
  
      System.out.println ( "The four digits integers are:" );
  
      System.out.printf ( "%d   %d   %d   %d\n%s\n", Digit1, Digit2, Digit3, Digit4, "Written by blabla" );
  
  }
  </code></pre>
  
  <h2>    }</h2>