title: Very simple game about Guessing The Number
body: <p>/hello, I am trying to learn how to use "break" commend in java as well as continuing loop with "y or n" choice. I am writing this game Guessing Number and I have some trouble with "y" choice. I will try to explain, to write a game of guessing number was easy so I started to add some conditions like the possibility on the and to play again or not, later I was thinking that would be more interesting if I add possibility to quit any time player wish, but that does not working correctly. Please help, thats my code</p>
  
  <pre><code>package guessinggame;
  import java.util.Random;
  import java.util.Scanner;
  
  /**
  *
  
  public class Main {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      System.out.println(" Welcome ");
  
      Random rand = new Random();
      Scanner input = new Scanner(System.in);
  
      boolean play_again = true;
      while (play_again)
      {
      int number_guess = rand.nextInt(100)+1;
      int number_of_tries = 0;
      int guess;
      String another = "y";
  
      boolean win = false;
      while (win == false)
      {
          System.out.println(" Try too guess a number between 1 and 100 ");
          guess = input.nextInt();
          number_of_tries++;
  
          if (guess == number_guess)
          {
              win = true;
          }
          else if (guess &lt; number_guess)
          {
              System.out.println(" Guess is too low " + "\n Guess another number to continue or n to quit ");
              if (input.hasNext("n"))
              {
                  play_again = false;
                  break;
  
              }
          }
          else if (guess &gt; number_guess)
          {
              System.out.println(" Guess is too high " + "\n Guess another number to continue or n to quit ");
              if (input.hasNext("n"))
              {
                  play_again = false;
                  break;
              }
          }
      }
  
      System.out.println(" You Win!!! ");
      System.out.println(" The number was " + number_guess);
      System.out.println(" It took you " + number_of_tries + " tries " +
              "\nWould you like to play again? (y/n): ");
      if (another.equalsIgnoreCase("y") == true)
          play_again = true;
      else 
      {
          play_again = false;
          }
      }
      }
  }
  </code></pre>