title: Need help coding Hangman
body: <p>This is my code for hangman for my Computer Science final. I need help figuring out how to tell players to choose a different letter if they guess a letter that has already been guessed. Any advice would be much appreciated!</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  
  public class HangmanJava
  {
      public static void main(String[] args)             
      {
          String input;
          boolean NotFullMan = true;                    
          char guessedLetter = ' ';                          
          Scanner hm = new Scanner(System.in);
          System.out.println("Enter the hangman word");
          input = hm.nextLine();                          
          List&lt;String&gt; letterGuesses = new ArrayList&lt;String&gt;();
  
          char[] charArray = input.toCharArray();             
          StringBuffer buffer = new StringBuffer(input.length());          
          int totalCorrect = 0;     
  
          for (int i = 0; i &lt; input.length(); i++)
              buffer.append('_');
  
          while (NotFullMan){
              System.out.println("Enter a letter");
              guessedLetter = hm.nextLine().charAt(0);         
              int correct = 0;
  
              for (int i=0; i &lt; charArray.length; i++){                
                  if(guessedLetter == charArray[i] &amp;&amp; buffer.charAt(i) == '_'){ 
                      correct++;
                      totalCorrect++;                         
                      buffer.setCharAt(i, guessedLetter);
                  }
              }
              System.out.println("You got " + correct + " correct!");
              System.out.println(buffer.toString());
  
              if (letterGuesses.contains(guessedLetter)){
                  System.out.println("Letter already chosen. Please pick another.");
              }
              else {
                  letterGuesses.append(guessedLetter);
              }
  
              if (totalCorrect == input.length()){
                  System.out.println("You win!");
                  return;
              } 
          }
      }
  }
  </code></pre>