title: Monty Hall Game
body: <p>I'm a new programmer currently in the process of learning Java. I've got a game here based on the game Let's make a deal &amp; the monty hall problem (<a href="https://www.youtube.com/watch?v=mhlc7peGlGg" rel="nofollow">https://www.youtube.com/watch?v=mhlc7peGlGg</a>) and I've been having issues with the logic for this code. Everything seems to be working right except that I can't seem to get the user_door to switch to the other door and determine if they are a winner correctly. If anybody can help me understand what I'm doing wrong here I would love to take this opportunity to learn, thanks! </p>
  
  <pre><code>import java.util.Random;
  import java.util.Scanner;
  public class GameShow {
  
  public static void main(String[] args) {
      Scanner scan = new Scanner (System.in);
      Random generator = new Random();
  
      // Initialize Variables
      int user_door,
          open_door,
          other_door,
          prize_door;
  
      // Generate random value 1-3
      prize_door = generator.nextInt(3)+1;
      open_door = prize_door;
  
      while(open_door == prize_door){
          open_door = generator.nextInt(3)+1;
      }
  
      other_door = open_door;
  
      while (other_door == open_door || other_door == prize_door){
          other_door = generator.nextInt(3)+1;
      }
  
      // Begin Game
      System.out.println("*** Welcome to the game show! ***");  
      System.out.println("Select the door (1, 2, or 3): ");
      user_door = scan.nextInt();
  
  
      // User Validation
          if (user_door &gt; 3 || user_door &lt; 0) {
              System.out.println("Please select door 1, 2, or 3");
              user_door = scan.nextInt();
          } else if(user_door == 1 || user_door == 2 ||  user_door == 3) {
  
      //Continue Game
      System.out.println("\nIn a moment, I will show you where the prize is located,");
      System.out.println("but first I will show you what is behind one of the other doors");
  
      //Continue Dialogue
      System.out.println("\nBehind door number " + open_door + " are goats!");
      System.out.println("You selected door number " + user_door);
      System.out.println("\nWould you like to switch your door(y/n)? ");
  
      //User Input Yes or No
      char userReply = scan.next().charAt(0);
  
      //If statement with nested while statements for user input
          if (userReply == 'y'){
                  user_door = other_door;
                  } while(userReply != 'y' &amp;&amp; userReply != 'n')
                  {
                      //User Validation
                      System.out.println("Please enter either y/n");
                      userReply = scan.next().charAt(0);
                  } 
  
      System.out.println("The prize is behind door number: " + prize_door); 
  
      //Check to see if user won or lost
          if(user_door == prize_door){
              System.out.println("Congratulations! You won the prize!");
              } else {
                      System.out.println("Sorry. You lost.");
                      }       
  
          }
      }
  }
  </code></pre>