title: Can't change a variable made outside a while loop inside the loop
body: <pre><code>public class Cow {
      public static void main(String [ ] args)
      {
          Scanner scan = new Scanner(System.in);
          System.out.print("Figure out a number between 1 and 100");
          int num = 4;
          int guess = scan.nextInt();
          if (guess == num) {
              System.out.println("Congratulations, you got it on your first try!");
          }
          int tries = 1;
          while (guess != num) {
              System.out.println("Incorrect. You have guessed: " + tries 
                      + " times. Guess again!");
              tries++;
              int guess = scan.nextInt();     
          }
          System.out.println("You have figured it out in " + tries + " tries.");}
      }
  } 
  </code></pre>
  
  <p>I created a variable called guess outside the while loop. When I try to change guess inside of the loop, it says that guess is a "duplicate local variable".</p>