Write a hangman game that randomly generates a word andprompts the user to guess one letter at a time, as presented in the sample run.Each letter in the word is displayed as an asterisk. When the user makes a correctguess, the actual letter is then displayed. When the user finishes a word, displaythe number of misses and ask the user whether to continue to play with anotherword. Declare an array to store words, as follows:// Add any words you wish in this arrayString[] words = {"write", "that",...}; (Guess) Enter a letter in word ******* > p↵Enter(Guess) Enter a letter in word p****** > r↵Enter(Guess) Enter a letter in word pr**r** > p↵Enterp is already in the word(Guess) Enter a letter in word pr**r** > o↵Enter(Guess) Enter a letter in word pro*r** > g↵Enter(Guess) Enter a letter in word progr** > n↵Entern is not in the word(Guess) Enter a letter in word progr** > m↵Enter(Guess) Enter a letter in word progr*m > a↵EnterThe word is program. You missed 1 timeDo you want to guess another word? Enter y or n>

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

Write a hangman game that randomly generates a word and
prompts the user to guess one letter at a time, as presented 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. 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↵Enter
(Guess) Enter a letter in word p****** > r↵Enter
(Guess) Enter a letter in word pr**r** > p↵Enter
p is already in the word
(Guess) Enter a letter in word pr**r** > o↵Enter
(Guess) Enter a letter in word pro*r** > g↵Enter
(Guess) Enter a letter in word progr** > n↵Enter
n is not in the word
(Guess) Enter a letter in word progr** > m↵Enter
(Guess) Enter a letter in word progr*m > a↵Enter
The word is program. You missed 1 time
Do you want to guess another word? Enter y or n>

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT