title: JAVA - End a loop after 10 repeats
body: <p>i'm writing a game where the user needs to guess a number between 0-100. the user has 10 tries to guess the right number and after every input he needs to get back a comment.
  so i wrote the code and everything works pretty good but i have a problem with breaking the loops after 10 wrong guesses and starting the game again once the game ends.
  anything would help. thank you in advace!</p>
  <pre><code>Scanner guess = new Scanner (System.in);
  Random hundred = new Random ();
  System.out.println (&quot;Welcome to Magic Number!&quot;);
  System.out.println (&quot;I'm thinking about a number between 0-100. You have 10 rounds to guess the right number.&quot;);
  System.out.println (&quot;Good Luck!&quot;);
  int number = hundred.nextInt(101);
  while (true) {
      System.out.println (&quot;What is the number i'm thinking about?&quot;);
      int guess1 = guess.nextInt();
       if (guess1 &gt; number) {
          System.out.println (&quot;The number you gueesed is higher than the number i'm thinking about!&quot;); 
      } else if (guess1 &lt; number) {
          System.out.println (&quot;This number you guessed is lower than the number i'm thinking about!&quot;);
      } else if (guess1 == number) {
          System.out.println (&quot;Congratulations! You've read my mind!&quot;);
          break;
      }
      
  }
  </code></pre>