Question: Using Java Write a hangman game that randomly generates a word and prompts the user to guess one letter at a time. Each letter in
Write a hangman game that randomly generates a word and prompts the user to guess one letter at a time. Each letter in the word is displayed as an asterisk. When the user makes a correct guess, the actual letter is then displayed. When the user finishes a word display the number of misses and ask the user whether to continue to play with another word. Declare an array to store words as follows: //add any words you wish in this array string[] words = {"write", "that', ' ) Hints To retrieve a hidden word from the array words, randomly generate an index based on the length of the array. Create a String array called guessedHord representing the guessed word and store asterisks in it. The length of the guessWord array should be equal to the length of the hidden word. To display the array guessedWord, use the following: System.out.print (" (Guess) Enter a letter in word+ String.join("", guessedWord)+ "> " 1. 2. 3. Here is a sample run (Guess) Enter a letter in word p (Guess) Enter a letter in word p***r (Guess) Enter a letter in word pr**r**p p is already in the word (Guess) Enter a letter in word pr"*t** > (Guess) Enter a letter in word prorg (Guess) Enter a letter in word progr**>n n is not in the word (Guess) Enter a letter in word progr>m (Guess) Enter a letter in word progr*m> a The word is program. You missed 1 time Do you want to guess another word? Enter y or n>n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
