Scanner input = new Scanner(System.in);
    String secretWord ;
    String guess, dash = "-", upWord;
    int numGuesses = 0;
    int numWord;
    final String SENTINEL = "!";
    System.out.println("Player 2, please look away.    Player 1, please enter  the secter word: \n");
    secretWord = input.next().toUpperCase().trim();
    numWord = secretWord.length();

    for(int dashNum = 1; dashNum < numWord; dashNum++) {
        dash += "-" ;
    }
    System.out.println("WordGuess game!\n");
    do {
        System.out.println("Enter a letter (" + SENTINEL + "to guess entire word): ");
        guess = input.next().toUpperCase().trim();
        numGuesses ++;
      if (secretWord.contains(guess) && guess.length() == 1)    {
            upWord = dash.substring(0, secretWord.indexOf(guess));
            upWord += guess;
            upWord += dash.substring(secretWord.indexOf(guess) + 1, dash.length());
            dash = upWord.toUpperCase();
            System.out.println(dash);
            if (dash.equals(secretWord))    {
                System.out.println("You won!\n" + "The secret word is " + secretWord);
                System.out.println("You made " + numGuesses + " guesses."); }
      } else    if (guess.length() >= 2)    {
            System.out.println("Please only enter one letter at a time! \n");   }               
            if (guess.contains(SENTINEL)) {
            System.out.println("What is your guess? ");
            guess = input.next().toUpperCase().trim();
            if (guess.equals(secretWord))   {
                System.out.println("You won!\n" + "The secret word is " + secretWord);
                System.out.println("You made " + numGuesses + " guesses.");
                break;
            } else {
                System.out.println("You Lose!");
                System.out.println("The secret word was " + secretWord);
                System.out.println("You made " + numGuesses + " guesses.");
                    break;
                }
            }
        }   while(!guess.contains(SENTINEL));
        input.close();  

    }

I don't understand your question! What do you mean "play the other player"?
Do you want to start a new game? If so, you need a second loop, like this pseudo-code

do {
  (here is the code to play one game)
  prompt "play again (yes/no)?"
while (reply is yes);

i think you need to type "hello" as the secret word..and debug

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.