title: have number input correlate to string using substring?
body: <p>I have to write a program following these guidelines. I have no Idea what I am doing. I have tried working through it, but can't seem to figure out how to get the input to correlate to the substring.</p>
  
  <p>Write a program that transforms 1,2,3...12 into the corresponding month January, February... Make a very long string "January February March... " in which you add spaces such that each month name has the same length. Then use substring to extract the month you want.</p>
  
  <p>Can someone please give me some guidance on this?</p>
  
  <p>We haven't worked with arrays or if statements yet, so I don't believe I should be using any of that either. – </p>
  
  <p>Ok here is what I have so far.</p>
  
  <pre><code>public class MonthIdentifier
  {
      private String monthNames = "January   February  March     April     May       June      July      August    September October   November  December  ";
      private int monthNumber;
  
      public MonthIdentifier(int month)
      {
          month = monthNumber;
      }
  
      public String getMonth()
      {
          int monthNameLength = 10;
          int end = monthNumber * monthNameLength;
          int start = end - monthNameLength;
          return monthNames.substring(start, end);
  
      }
  }
  </code></pre>
  
  <p>Here is the main</p>
  
  <pre><code>import java.util.Scanner;
  
  public class ChooseMonth
  {
      public static void main(String[] args)
      {
  
          Scanner input = new Scanner(System.in);
          System.out.print("Enter Number 1-12: ");
          int month = input.nextInt();
          MonthIdentifier newMonth = new MonthIdentifier(month);
  
          newMonth.getMonth();
          String monthName = newMonth.getMonth();
          System.out.println(month + " : " + monthName);
  
  
      }
  }
  </code></pre>
  
  <p>I have updated my code to what I have so far. I am getting an error:</p>
  
  <blockquote>
    <p>exception in thread Main String Index out of range: -10</p>
  </blockquote>
  
  <p>Also I forgot to mention I have to take user input 1-12 and have it correlate to the substring for that month.</p>