title: How to print each number up to a certain number
body: <p>I am taking an online MOOC to learn Java, the only problem i have is it is from the university of Helsinki in Finland i live in the US so there are limited times when i can be awake to ask for help on an exercise. my current exercise is to ask the user for a number and then print each whole number up to that number while using a </p>
  
  <pre><code>    while {
     } 
  </code></pre>
  
  <p>statement </p>
  
  <p>this is the code i have currently</p>
  
  <pre><code>    public static void main(String[] args) {
      Scanner reader = new Scanner(System.in);
  
      int number = Integer.parseInt(reader.nextLine());
      System.out.print("up to what number?:"+ number);
      while (number&lt;=number){ 
          System.out.println(number);
          number++;
      }
  }
  </code></pre>
  
  <p>and what it looks like it is doing is ignoring the </p>
  
  <pre><code>    while (number&lt;=number) {
      System.out.println(number);
  </code></pre>
  
  <p>part of my code and proceeding straight to the </p>
  
  <pre><code>    number++;
  </code></pre>
  
  <p>portion of my code do i need to declare another int(variable) to store a value? 
  the way the course has the test cases for grading i can't simply declare a variable with a definite value as they run several test cases like positive numbers and negative numbers.
  is there a way to use the reader to store a value to two separate variables so that they can be compared against each other and only print the numbers up to that number? </p>
  
  <p>i also know that i am missing a </p>
  
  <pre><code>   Break;
  </code></pre>
  
  <p>statement but i am not sure where i would place it in the code i have, i have tried to use </p>
  
  <pre><code>    } else {
       break;
  </code></pre>
  
  <p>but get an error stating that i have an else without an if.
  i am using netbeans as it is required for my course because the server submissions are setup through TMC.</p>
  
  <p>thinking about it now i'm sure its not skipping the while statement but simply continues to print because as it prints and increments the users input is incremented as well since i only have the one variable but i am again not sure how i would go about storing the user input value in two different variables where i can compare them with the less than or equal to statement and stop the printing once it reaches the number input by the user, in that case i would not necessarily need the break statement as it would stop once it prints up to the number input.</p>
  
  <p>ANSWERED: here is what i finally came up with as my answer.</p>
  
  <pre><code>    public static void main(String[] args) {
      Scanner reader = new Scanner(System.in);
      System.out.print("up to what number?:");
      int numbers = 1;
      int number = Integer.parseInt(reader.nextLine());
  
      while (numbers &lt;= number){ 
          System.out.println(numbers);
          numbers++;
      }
  }
  </code></pre>