title: Java Odd Number Loop
body: <p>I am trying to output the first "x" odds, but I am clueless on how to stop the loop at the number that x is. For example... if you input 6, I want it to show 1, 3, 5, 7, 9, 11. However, my coding does it for all the odds.</p>
  
  <pre><code>import java.util.Scanner;
  
  
  public class OddNumber {
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
  
      System.out.println("Please input a number.");
      Scanner keyboard = new Scanner(System.in);
      int x = keyboard.nextInt();
      int total = x*x;
      if (x &gt; 0){
          System.out.println("The first 5 odd numbers are...");
      }
      if (x &gt; 0){
          for (int i = 0; i &lt; total; i++){
          if (i % 2 != 0){
              System.out.println(i+"");
          }}
      System.out.println("The total is "+total);
      }
  
          }
  
  
  }
  </code></pre>