title: Hailstone Program in Java
body: <p>I have the following program to write:</p>
  
  <blockquote>
    <p>An interesting (yet unsolved) question in mathematics is called "hailstone numbers". This series is produced by taking an initial integer and if the number is even, dividing it by 2. If the number is odd, multiply it by 3 and add 1. This process is the repeated.
    <p>
    <strong>For example</strong>: An initial number of 10 produces: 10, 5, 16, 8, 4, 2, 1, 4, 2, 1... An initial value of 23 produces: 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1...</p>
    
    <p>Note that both numbers eventually reach the 4, 2, 1, 4, 2, 1... cycle.</p>
    
    <p>Create an application that offers the user three different ways to run this program.
    <li><strong>Option 1</strong>: Print the hailstone numbers for a single entry and its length<br>
    <em>Example</em>: Input> 10 10, 5, 16, 8, 4, 2, 1 Length 7
    <li><strong>Option 2</strong>: Print all of the hailstone numbers from 4 to a given entry<br>
    <em>Example</em>: Input> 6 4, 2, 1 Length 3 5, 16, 8, 4, 2, 1 Length 6 6, 3, 10, 5, 16, 8, 4, 2, 1 Length 9
    <li><strong>Option 3</strong>: Print out the number with the maximum number of iterations need to reach the cycle and which starting number produces this maximum from 4 to the number entered.<br>
    <em>Example</em>: Input> 6 Longest: 6 Length: 9</p>
    
    <p>In writing this program you must implement the following method...</p>
  </blockquote>
  
  <pre><code>/** 
   * 
   * @param num  Number that a hailstone chain will be generated 
   * @param showNumbers  true if list of numbers is shown to screen 
   * @return  Count of the numbers in the num hailstone chain.
   */
  private static int hailStone(int num, boolean showNumbers) {
      // your code
  }
  </code></pre>
  
  <hr>
  
  <p>This is the code I've written so far:</p>
  
  <pre><code>public static void main(String[] args) {
          int a = getInt("Give a number: ");
  
          System.out.print("How would you like to run the program? Option 1 prints hailstone numbers for a single entry and its length." +
                  "Option 2 prints all the hailstone numbers from 4 to a given entry. Option 3 prints the number with the maximum number" +
                  "of iterations needed to reach the 4, 2, 1 cycle.");
          int option = console.nextInt();
  
          boolean showNumbers = (option == 1 || option == 2);
  
          hailStone(a, showNumbers);
      }
  
      public static int getInt(String prompt) {
          int input;
  
          System.out.print(prompt);
          input = console.nextInt();
  
          return input;
      }
  
      private static void hailStone (int a, boolean showNumbers) {
          if (showNumbers == true) {
              if (a % 2 == 0) {
                  for (int i = 0; i &lt; 50; i++) {
                     for (int j = 0; j &lt;= i; j++)
                      a /= 2;
                      System.out.print(a + " ");
                      a *= 3;
                      a += 1;
                      System.out.print(a + " ");
                  }
  
              } else {
                  for (int i = 0; i != a; i++) {
  
                  }
              }
          } else {
  
          }
      }
  </code></pre>
  
  <p>I feel like I've hit a brick wall because I have no idea how to implement all these options in the method my teacher is requiring us to use. Plus, I can't seem to get even the basic hailstone chain to print. Help?</p>