title: How do I ask the user to "play again" and rerun the do while loop with a simple yes or no question?
body: <p>So I added the yes or no statement prints out but it doesn't allow the user to type it in. How do I fix that and can I nest a while loop inside a do-while loop?</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.Scanner;
  import java.util.Random;
  
  public class HiLo {
      public static void main(String[] args) {
          Random random = new Random();
          Scanner input = new Scanner(System.in);
          final int MAX = 100;
          int answer = random.nextInt(MAX) + 1;
          int guess = -1;
          int numberOfGuesses = 0;
          String cont;
  
          System.out.println("Guess a number between 1 and " + MAX + ": ");
  
          do {
              while (guess != answer) {
                  numberOfGuesses++;
                  guess = input.nextInt();
  
                  if (guess == 101) {
                      break;
                  } else if (guess &gt; answer) {
                      System.out.println("Too High");
                      System.out.println("\nGuess again ");
                  } else if (guess &lt; answer) {
                      System.out.println("Too Low");
                      System.out.println("\nGuess again: ");
                  } else {
                      System.out.println("Correct! The number was " + answer + ".");
                      System.out.println("It took you " + numberOfGuesses + " guesses.");
                  }
              }
  
              System.out.println("\nWould you like to play again (yes/no)?");
              cont = input.nextLine();
          } while (cont.equals("yes");
  
          input.close();
      }
  }
  </code></pre>