title: how to use input in different loops
body: <p>I have the following error</p>
  <blockquote>
  <p>cannot find symbol: variable num</p>
  </blockquote>
  <p>in all the <code>if</code> statements.</p>
  <p>This is my current code.</p>
  <pre><code>Scanner console = new Scanner(System.in);
   int min = Integer.MAX_VALUE;
      int max = Integer.MIN_VALUE;
  
  do{System.out.println(&quot;Type a number (or -1 to stop): &quot;);
     int num = console.nextInt();
    }while(!num == -1);{
     System.out.print(+ num );
     }if (min &lt; num) {
         num = min;
     }if (num &gt; max) {
           max = num;
        } 
       
      System.out.println(&quot;maximum was : &quot; + max);
     System.out.println(&quot;minimum was : &quot; + min);
  }
  </code></pre>
  <p>Help.</p>