Question: Implement and Test the hangman program as specified below. Display all words extracted from data file (hangman.dat) to output window. Data file may contain any
- Implement and Test the hangman program as specified below.
- Display all words extracted from data file (hangman.dat) to output window.
- Data file may contain any number of words with words delimited by newlines.
- The word to guess should be the last word from the data file (hangman.dat)
- Display word to guess at beginning of program in all CAPS.
- The program should prompt the user for a letter to guess and program will convert the letter to a CAPITAL.
- Indicate to the user whether or not the letter to guess was valid or invalid (case insensitive search).
- Draw the hangman board that corresponds to the number of wrong guesses. The board will display after each guess for both correct and incorrect guesses.
- The program should keep track of the number of wrong guesses and only allow the user to keep guessing if they have not incorrectly guessed the complete hangman (6 wrong guesses means player loses game).
- The user cannot win the game yet or guess the word correctly yet.
- Make sure to follow all Grading Rubric items and the Academic Misconduct Policies.
- Display all words extracted from data file (hangman.dat) to output window.
- Here is a sample run of the program.
-
Here is what I have so far: -
#include
using namespace std; ///driver function int main() { string BOARD1 = " -------| | | | | | | ----- "; string BOARD2 = " -------| | | O | | | | ----- "; string BOARD3 = " -------| | | O | | | | | ----- "; string BOARD4 = " -------| | | O | -| | | | ----- "; string BOARD5 = " -------| | | O | -|- | | | ----- "; string BOARD6 = " -------| | | O | -|- | / | | ----- "; string BOARD7 = " -------| | | O | -|- | / \\ | | ----- "; cout > word; char c; cout > c; bool flag = false; for (int i = 0; i
Word: computer Word: science Word: programming Word to Guess: PROGRAMMING Enter a letter to guess: 0 You entered: 0 Enter a letter to guess: w You entered: W w is NOT in the word to guess. 0 is in the word to guess. 0 I Enter a letter to guess: e You entered: E Enter a letter to guess: * You entered: X Enter a letter to guess: g You entered: G G is in the word to guess. E is NOT in the word to guess. X is NOT in the word to guess. 1 0 Enter a letter to guess: P You entered : P Enter a letter to guess: y You entered: Y Y is NOT in the word to guess. Enter a letter to guess: Y You entered: Y Y is NOT in the word to guess. P is in the word to guess. Press any key to continue .. Enter a letter to guess: 2 You entered: Z Z is NOT in the word to guess
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
