title: My scanner methods aren't working and the while-loop won't break
body: <p>I'm a beginner and don't know what is wrong with my program.</p>
  
  <p>What I would like the program to do is to allow the user to enter an Integer that is under MAX (1 000 000 000) but above 0. I also have put an exception block using the <code>try</code> and <code>catch</code> methods so that the user cannot enter a String. </p>
  
  <p>The exception block works but it also prints the statements inside the <code>if</code> block, which I don't want. </p>
  
  <p>This is what the console prints:</p>
  
  <pre><code>Number of marbles to divide: 
  *three*
  Please enter a number not a word
  Try again: 
  Please enter a number under 1 000 000 000 and above 0
  Try again: 
  </code></pre>
  
  <p>I only want it to print... <code>Please enter a number not a word Try again:</code> after the user enters a String. What I mean is that I want the method's while-loop to break if the user has entered a string.</p>
  
  <p>Another problem that I can't seem to solve is that if the user enters an Integer that's value is over MAX (1 000 000 000), the program continues. This is what the console prints.</p>
  
  <pre><code>Number of marbles to divide: 
  1000000001
  Number of people: 
  </code></pre>
  
  <p>As you can see the program continues even though the user has entered an Integer over MAX (1 000 000 000)</p>
  
  <p>This is my code:</p>
  
  <pre><code>import java.util.*;
  
  public class MarblesApp
  {
      final static int MAX = 1000000000;
      static int  numberOfMarbles;
      static int numberOfPeople, marblesPerPerson, marblesLeftOver;
      static Scanner input = new Scanner(System.in);
      public static void main(String[] args) 
      {
          System.out.println("Welcome to the marble divvy-upper.");
          System.out.println("This program will tell you how many marbles to give to each person.\n"
      + "The maximum amount of marbles is 1 000 000 000. The maximum amount of people is the same.\n");
  
          System.out.println("Number of marbles to divide: ");
            numberOfMarbles = GetMarbles();
  
          System.out.println("Number of people: ");
            numberOfPeople = GetPeople();
  
          marblesPerPerson = (int)numberOfMarbles / numberOfPeople;
          marblesLeftOver = (int)numberOfMarbles % numberOfPeople;
  
          System.out.println("Give each child " + marblesPerPerson + " marbles."); 
          System.out.println("You will have " + marblesLeftOver + " marbles left over.");
      }
  private static int GetPeople()
  {
      while (true)
      {
          try
          {
              return input.nextInt();
          }
          catch(InputMismatchException f)
          {
              input.next();
              System.out.println("Please enter a number not a word\nTry again: ");
          }
  
          if(numberOfPeople &gt; MAX || numberOfPeople == 0);
          {
              System.out.println("Please enter a number under 1 000 000 000 and above 0\nTry again: ");
          }
      }
  }
  public static int GetMarbles()
  {
      while (true)
      {
          try 
          {
              return input.nextInt();
          }
          catch (InputMismatchException e)
          {
              input.next(); 
              System.out.println("Please enter a number not a word\nTry again: ");
          }
  
          if(numberOfMarbles &gt; MAX || numberOfMarbles == 0);
          {
              System.out.println("Please enter a number under 1 000 000 000 and above 0\nTry again: ");
          }
  
          }
      } 
  }
  </code></pre>