title: Why does my if-chain not stop?
body: <p>I was running a program with my students today and we came to a method that asked them to create conditional statements that prompts the user on the day of week after an input of 1 - 7 which correspond to Sunday to Saturday.  </p>
  
  <p>A student came up with the code below which prints out "Thursday", but it also prints out the else statement.  I cannot figure out why it does not stop at d == 5. But when I changed the method to return a String and had each if statement return a String like "Sunday" it worked.  The code is below.  Why does the program not stop for the void method, but stop for the String method?</p>
  
  <pre><code>public static void dayOfWeek(int d) //This did not stop at d == 5.
      {
          if (d == 1)
          {
              System.out.println("Sunday");
          }
          if (d == 2)
          {
              System.out.println("Monday");
          }
          if (d == 3)
          {
              System.out.println("Tuesday");
          }
          if (d == 4)
          {
              System.out.println("Wednesday");
          }
          if (d == 5)
          {
              System.out.println("Thursday");
          }
          if (d == 6)
          {
              System.out.println("Friday");
          }
          if (d == 7)
          {
              System.out.println("Saturday");
          }
          else
          {
              System.out.println("Oops! Number must be between 1 and 7");
          }
      }
  
  public static String dayOfWeek(int d) //This worked at d == 5.
  {
      if (d == 1)
      {
          return "Sunday";
      }
      if (d == 2)
      {
          return "Monday";
      }
      if (d == 3)
      {
          return "Tuesday";
      }
      if (d == 4)
      {
          return "Wednesday";
      }
      if (d == 5)
      {
          return "Thursday";
      }
      if (d == 6)
      {
          return "Friday";
      }
      if (d == 7)
      {
          return "Saturday";
      }
      else
      {
          return "Oops! Number must be between 1 and 7";
      }
  }
  </code></pre>