Question: Java help Write a hangman game that randomly generates a word and prompts the user to guess one letter at a time, as shown in

Java help

Write a hangman game that randomly generates a word and prompts the user to guess one letter at a time, as shown in the sample run. 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. Hint: StringBuilder will be very helpful in solving the problem.

Declare an array to store words, as follows:

// Add any words you wish in this array

String[] words = {"write", "that", ...};

(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**r** > o

(Guess) Enter a letter in word pro*r** > g

(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>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!