title: Java letter guessing program
body: <p>I'm trying to make this simple game. But I have no idea what's wrong with this code. Here's my code so far:</p>
  
  <pre><code>import java.util.*;
  import java.lang.*;
  
  public class letterguess {
      private static String[] animals = {"snake","dog","cat","bird","whale","ant","wolf","bear","mouse","rabbit","elephant","dragonfly","kangaroo","tiger","komodo","koala","chicken","lion","horse","goat","cow","gorilla","camel","chipmunk","octopus","lobster","phanter","frog","zebra","lizard","baboon","deer","bison","hamster","hyena","shark"}; 
      public static void main(String[] args) {
  
          String [] true_answer = {"Right", "Awesome", "Cool"};
          String [] false_answer = {"Wrong answer!", "Oops!"};
          String [] word;
          String [] show_word;
  
          Random string = new Random();
  
          int i, n=0, start, random=0, z=0, word_size, size;
          char tryagain=0;
          boolean output=true, main=true, error=true;
  
          System.out.print ("Press 1 to start, 2 to exit: ");
          Scanner input = new Scanner(System.in);
          start = input.nextInt();
  
          if (start==1){
              main=true;
          }
          else{
              System.exit(0);
          }
  
          while(main){
              random = string.nextInt(animals.length);       
              word = animals[random].split("");                             
              show_word = animals[random].split("");                    
  
              for(word_size=0;word_size&lt;animals[random].length();word_size++){
                  n=word_size;
              }                                           
  
              for(i=1;i&lt;animals[random].length();i++){    
                  show_word[i] = "_";
              }
  
              if(n==3){     
                  for(i=0;i&lt;1;i++){
                      size = (int) (Math.random()*n);
                      show_word[size]=word[size+1];
                  }
              }   
              else if(n==4){
                  for(i=0;i&lt;2;i++){
                      size = (int) (Math.random()*n);
                      show_word[size]=word[size+1];          
                  }
              }
              else if(n==5){
                  for(i=0;i&lt;2;i++){
                      size = (int) (Math.random()*n);
                      show_word[size]=word[size+1];
                  }
              }
              else if(n==6){
                  for(i=0;i&lt;3;i++){
                      size = (int) (Math.random()*n);
                      show_word[size]=word[size+1];
                  }
              }
              else if(n&gt;=7){
                  for(i=0;i&lt;4;i++){
                      size = (int) (Math.random()*n);
                      show_word[size]=word[size+1];
                  }
              }
  
              do{ 
                  for(i=0;i&lt;animals[random].length();i++){
                      System.out.print(show_word[i]);      
                  }
  
                  try {
                      Thread.sleep(1000);
                  } catch (InterruptedException ie) {
                  }
                  System.out.print("\t 1");
                  try {
                      Thread.sleep(1000);
                  } catch (InterruptedException ie) {
                  }
                  System.out.print(" 2");
                  try {
                      Thread.sleep(1000);
                  } catch (InterruptedException ie) {
                  }
                  System.out.print(" 3");
                  try {
                      Thread.sleep(1000);
                  } catch (InterruptedException ie) {
                  }
                  System.out.print(" 4");
                  try {
                      Thread.sleep(1000);
                  } catch (InterruptedException ie) {
                  }
                  System.out.print(" 5 ");
  
                  System.out.print("\n Answer: ");
                  Scanner input2 = new Scanner(System.in);         
                  String word3 = input2.nextLine();          
  
  
                  if(word3.equals(animals[random])){ 
                      int True = (int) (Math.random()*2+1);
                      System.out.println(" ==&gt; " +true_answer[True]);
                      output=false;
                  }
                  else{
                      int False = (int) (Math.random()*2+1);
                      System.out.println(" ==&gt; "+false_answer[False]+"\n");
                      output=false;
                  }
              }while(output);
  
              System.out.print("\n Try Again (Y/N) : ");
              Scanner input3= new Scanner (System.in);
              tryagain = input3.next().toLowerCase().charAt(0);
              if(tryagain=='y') 
                  main=true; 
              else if(tryagain=='n')  
                  main = false;
  
              else
                  while(error){
                      System.out.print ("\n Wrong Input. Please input Y or N: ");
                      Scanner input4= new Scanner (System.in);
                      String next=input4.nextLine();
                      if(next.equals("Y")||next.equals("y"))
                          break;
                      else if(next.equals("N")||next.equals("n")){
                          error=false;
                          main=false;
                      }
                      else
                          continue;     
                  }
  
          }  
          System.out.print ("\t\t\t(\tGAME OVER\t)");    
  
      }
  }
  </code></pre>
  
  <p>The problem is, the output is not something I expected. 
  I expect something like <strong>ho_s_</strong> for <strong>horse</strong> or <strong>_l_ph___</strong> for <strong>elephant</strong> but it shows something like <strong>or_e_</strong> for <strong>horse</strong> and <strong>ee___nt_</strong> for <strong>elephant</strong>.</p>
  
  <p>Can someone fix this for me? I've tried anything that I know and still can't fix it. I'm sorry before and thank you.</p>