title: Java looping 3 times before giving correct output
body: <p><br>
  I'm making an application that quizzes you on politics or astronomy. </p>
  
  <p>My problem is that when you say "politics" or you say "astronomy", it will ask you again 2 more times for your input, before giving the desired output of "test". </p>
  
  <p>Here's the code:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Main {
      public static void main(String[] args) {
          do {
              if (getAnswer().equalsIgnoreCase("neither")) {
                  System.out.println("Please enter \'astronomy\' or \'politics\'.");
              }
          getAnswer();
          }
          while(getAnswer().equalsIgnoreCase("neither"));
      System.out.println("test");
      }
      public static String getAnswer() {
          Scanner quizType = new Scanner(System.in);
          System.out.println("Would you like to be quizzed on politics or astronomy?");
          String typeAnswer = quizType.next();
          if (typeAnswer.equalsIgnoreCase("politics")) {
              return "politics";
          }
          else if (typeAnswer.equalsIgnoreCase("astronomy")) {
              return "astronomy";
          }
          else {
              return "neither";
          }
      }
  }
  </code></pre>
  
  <p>Any ideas?<br>
  Thanks</p>