Question: Rewrite Programming Exercise 7.35 . The program reads the words stored in a text file named hangman.txt. Words are delimited by spaces. Write a hangman
Rewrite Programming Exercise 7.35. The program reads the words stored in a text file named hangman.txt. Words are delimited by spaces.
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. 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 JErter (Guess) Enter a letter in word p****** > r JErter (Guess) Enter a letter in word pr**r** > p -Erter p is already in the word (Guess) Enter a letter in word pr**r** > o -Ercer (Guess) Enter a letter in word pro*r** > g Jtrter (Guess) Enter a letter in word progr** > n -Eroer n is not in the word (Guess) Enter a letter in word progr** > m JErter (Guess) Enter a letter in word progr*m > a -Erter The word is program. You missed 1 time Do you want to guess another word? Enter y or n>
Step by Step Solution
3.46 Rating (172 Votes )
There are 3 Steps involved in it
A program to demonstrate the Hangman game where the words are choosen from ... View full answer
Get step-by-step solutions from verified subject matter experts
