Write a game of hangman using arrays. Allow the user to guess letters until the
ID: 3539104 • Letter: W
Question
Write a game of hangman using arrays. Allow the user to guess letters until the guess a word correctly within the parameters of the game. Also use an array to represent which letters have been guessed already to keep track. (see http://playhangmangames.com/ as an example. Skip the advertisement)
Things to keep in mind:
1. Create a file containing at least 10 words. These will represent the words used in the game. You can expand the game to include more than 10 words if you wish. When the program starts, store these words into an array of strings.
2. When the game starts, the program should randomly choose a word from the array of strings as described in #1.
3. The player tries to guess the letters that are in the word. The game continues until the user either guesses the whole word/ letters, or they run out of turns. Each time the user guesses an incorrect letter, part of the gallows should be displayed. There should be eight body parts to the person: head, torso, leftArm, rightArm, LeftLeg, rightLeg, leftFoot and Rightfoot. You should use characters to represent the figure.
4. The game ends by either the users guessing the characters in the word without making any more than 7 mistakes. Or if the user makes 8 incorrect guesses.
Sample Run:
Hangman Game!
You have guessed the following letters:
_ _ _ _ _
Enter a letter: //let%u2019s say the users types %u2018u%u2019
You have guessed the following letters: u
_ _ u _ _
Enter a letter: //let%u2019s say the user types %u2018s%u2019
S! not found. 7 more guesses remain.
_____
O | //the head is drawn
|
|
|
______
You have guessed the following letters: u , s
_ _ u _ _
Enter a letter: //the user enters %u2018h%u2019
You have guessed the following letters: u , s , h
h _ u _ _
%u2026..
Explanation / Answer
You could split the WORD to be guessed in an array. Let's say the word is AWESOME, and you allow 5 wrong guesses. put each character from WORD in an array. Have the user to input only 1 character int wrong = 0; int counter = 0; keeping track of how many matches; Create a while loop with the condition of Wrong variableRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.