title: How do I check if the reader's input is between 500 and 1000? I am not sure if I'm on the right track
body: <p>I am supposed to ask the reader to input a number and then check if it's between 500 and 1000, so i can add up the digits.  But i don't know how to check if the number is between the interval.  </p>
  
  <pre><code>import java.util.Scanner;
  public class AddNumbers {
    public static void main(String[]args){
      Scanner input = new Scanner (System.in);
      //Prompt user to enter number
      System.out.println("Enter a number between 500 and 1000:");
        String number;
      number=input.nextLine();
  
      //Get digits from number
      char numberDigit1 = number.charAt(0);
      char numberDigit2 = number.charAt(1);
      char numberDigit3 = number.charAt(2);
  
      //initialize variable
      String constant=500;
      String constant2=1000;
  
  while (number.CompareTo(constant)){
    System.out.println("The sum of the digits is: " + ((number.charAt(0) +      (number.charAt(1) + (number.charAt(2))))));
                                                                            }
  while (number.CompareTo(constant)){
    if (number&lt;=0)
    System.out.println("****ERROR: THE NUMBER MUST BE BETWEEN 500 AND     1000****");
  }
  
  while (number.CompareTo(constant2)){
    if (number&gt;=0)
      System.out.println("****ERROR: THE NUMBER MUST BE BETWEEN 500 AND 1000****");
  }
  
  
      input.close();
    }
  }                                                 
  </code></pre>