title: Birthday guesser in Java, code lines are skipped for no obvious reason
body: <p>I am working on an exercise from the book "Introduction to Java Programming" by Y. Daniel Liang. In this program the user is presented a table with various dates in a month. If the users birthday is in the presented table, the user prompts 'Y' for yes, and 'N' for no. Depending on how many times to useres prompts 'Y', the program should guess what day of the month the users birthday is. When I run the program, and the first set of dates is displayed, I type in either 'Y' or 'N'. Then set2 and 3 are printed, but i don't get to type in any input. When set 4 is printed, I can type input again, but after set 5 is printed, no input can be typed. Why can I only type in input after set1 and 4? Code is displayed below:</p>
  
  <pre><code>import java.util.Scanner;
  
  
  public class GuessBirthday {
  
  public static void main(String[] args)
          throws java.io.IOException {
  
  String set1 = 
      "  1  3  5  7\n" +
      "  9 11 13 15\n" +
      " 17 19 21 23\n" + 
      " 25 27 29 31";
  
      String set2 = 
      "  2  3  6  7\n" +
      " 10 11 14 15\n" +
      " 18 19 22 23\n" + 
      " 26 27 30 31";
  
      String set3 = 
      "  4  5  6  7\n" +
      " 12 13 14 15\n" +
      " 20 21 22 23\n" + 
      " 28 29 30 31";
  
      String set4 = 
      "  8  9 10 11\n" +
      " 12 13 14 15\n" +
      " 24 25 26 27\n" + 
      " 28 29 30 31";
  
      String set5 = 
      " 16 17 18 19\n" +
      " 20 21 22 23\n" +
      " 24 25 26 27\n" + 
      " 28 29 30 31";
  
      int day = 0;
  
      // Create a scanner
  
      Scanner input = new Scanner(System.in);
  
      // Prompt the user to answer questions
  
      System.out.print("Is your birthday in set1?\n");
      System.out.print(set1);
      System.out.print("\nEnter (Y) for yes or (N) for no: ");
      char answer = (char) System.in.read();
  
      if (answer == 'Y')
          day += 1;
  
      System.out.print("\nIs your birthday in set2?\n");
      System.out.print(set2);
      System.out.print("\nEnter (Y) for yes or (N) for no: ");
      answer = (char) System.in.read();
  
      if (answer == 'Y')
          day += 2;
  
      System.out.print("\nIs your birthday in set3?\n");
      System.out.print(set3);
      System.out.print("\nEnter (Y) for yes or (N) for no: ");
      answer = (char) System.in.read();
  
      if (answer == 'Y')
          day += 4;
  
      System.out.print("\nIs your birthday in set4?\n");
      System.out.print(set4);
      System.out.print("\nEnter (Y) for yes or (N) for no: ");
      answer = (char) System.in.read();
  
      if (answer == 'Y')
          day += 8;
  
      System.out.print("\nIs your birthday in set5?\n");
      System.out.print(set5);
      System.out.print("\nEnter (Y) for yes or (N) for no: ");
      answer = (char) System.in.read();
  
      if (answer == 'Y')
          day += 16;
  
      System.out.println("\nYour birthday is " + day + "!");
  
      }
  }
  </code></pre>