title: Hangman Part 2 with Arrays Java
body: <p>Well now in class we were assigned another Hangman Project with the use of Arrays and we have to generate " _ "'s.
  I have successfully generated all the blanks when the user inputs the "wordAnswer".
  My problem is that I cant figure out how to replace the correct guess char with the blank " _ ". </p>
  
  <p>Here is my code for whole program and I know its not all complete.</p>
  
  <pre><code>import cs1.Keyboard;
  public class Game {
  
      public static void main(String[] args) {
          int correctGuess = 0;
          int wrongGuess = 0;
          int bodyParts = 0;
          char guess;
          boolean foundIt;
          System.out.println("Welcome to Hangman!");
          System.out.println("Please enter a word for the other user to guess!");
          String wordAnswer = Keyboard.readString();
          char[] chars = wordAnswer.toCharArray();
          char[] blanks = new char[wordAnswer.length()];
  
          System.out.println("You have 6 attempts to guess the word!");
          do {
              for (int i = 0; i &lt; wordAnswer.length(); i++) {
                  System.out.print(" _ ");
              }
              System.out.println("Please enter in your guess!");
              guess = Keyboard.readChar();
              for (int i = 0; i &lt; chars.length; i++) {
                  if (guess == chars[i]) {
                      blanks[i] = guess;
                      foundIt = true;
                  }
              }
          } while (correctGuess &lt; wordAnswer.length() &amp;&amp; wrongGuess != 6); {
              System.out.println("Congratulations! You have solved the word!");
          }
      }
  }
  </code></pre>
  
  <p>I know that you have to use a for loop to be able to change the blank to the correct guessed letter but when you run the program and enter in your the correct guess the blank does not change into the correct letter. 
  Here is my OutPut</p>
  
  <pre><code> Welcome to Hangman!
  Please enter a word for the other user to guess!
  program
  You have 6 attempts to guess the word!
   _  _  _  _  _  _  _ Please enter in your guess!
  p
   _  _  _  _  _  _  _ Please enter in your guess!
  r
   _  _  _  _  _  _  _ Please enter in your guess!
  o
   _  _  _  _  _  _  _ Please enter in your guess!
  g
   _  _  _  _  _  _  _ Please enter in your guess!
  r
   _  _  _  _  _  _  _ Please enter in your guess!
  a
   _  _  _  _  _  _  _ Please enter in your guess!
  m
   _  _  _  _  _  _  _ Please enter in your guess!
  </code></pre>
  
  <p>What I am expecting is!!</p>
  
  <pre><code>    Welcome to Hangman!
  Please enter a word for the other user to guess!
  program
  You have 6 attempts to guess the word!
   _  _  _  _  _  _  _ Please enter in your guess!
  p
   p  _  _  _  _  _  _ Please enter in your guess!
  r
   p  r  _  _  _  _  _ Please enter in your guess!
  o
   p  r  o  _  _  _  _ Please enter in your guess!
  </code></pre>
  
  <p>etc...</p>
  
  <p>This is what I have but tips and help would be very appreciative!!</p>
  
  <pre><code>System.out.println("Please enter in your guess!");
          guess = Keyboard.readChar();
          for (int i = 0; i &lt; chars.length; i++) {
              if (guess == chars[i]) {
                  blanks[i] = guess;
                  foundIt = true;
              }
          }
  </code></pre>