Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Must work in C environment Program Description: Using the program earlier, write

ID: 3614689 • Letter: M

Question

Must work in C environment

Program Description:
Using the program earlier, write a "hangman game" program in whichthe user attempts to guess all the letters in a "mystery word"chosen from the data file provided by the user. The user should beallowed to play as many game as he wishes before quitting. For eachgame, the program should randomly select a new word from the array.The user should be shown the secret word as a series of dashes. Thenumber of dashes should correspond to the number of letters in theword. (If the word is "hello" the program would print out:-----)

The program should request that the user enter guesses as to theletters in the secret word. After each guess, a list of all lettersthat the user has guessed so far should be printed out, followed bythe latest version of the "word so far" with the correctly guessedletters in place of the dashes. If the user makes nine incorrectguesses before guessing all the letters contained in the word, thenprint out a "You Lose" message together with the chosen word. Ifthe user guesses all the correct letters in the chosen word, printthe word with a "You Win!" message. Whether the user wins or loses,the program should allow him to play again (see the sampleexecution below)

Specifications:
Program should have at least 2 functions in addition to previoushangman exercise.

1) a function of type int called good_guess that checks to seewhether the most recent letter input by the user is a lettercontained in the mystery word. If so, the function returns 1.Otherwise, the function returns 0.

2) a function called print_guessed_letters that will print to thescreen all letters previously guessed during this game, includingboth correct and incorrect letters. (This reminds the user whichletters are used up and which ones are remaining.)

3) initialize a cstring called "word_so_far" with dashes for eachletter of the chosen word, and a null terminator at the end to showwhere the word ends. (Hint: you will need to use the functionstrlen to determine the length of the word)

4) You will also need to modify the function get_random() which youwrote earlier, so that it will not choose the same "random" wordeach time it is called. To do this, you need to "seed" the randomnumber outside the function which returns the random array element.Also, you should "seed" the random number generator with the systemtime, rather than with a constant, in order to have different wordschosen each time the game is played.

5) The program may assume that the user will enter valid guesses(i.e. uppercase or lowercase alphabet letters). You need not checkfor type errors, such as the user entering a numeric value insteadof an alphabetical one.

Sample Execution:
---------------------------------
Enter the hangman word file name: hangman.dat
---------------------------------
This is a fun word game hangman

Here is your word so far: --------

Enter a new letter: R
Sorry! That letter is not in the chosen word!
The letters you have guessed so far are: R
Here is your word so far: --------

Enter a new letter: s
Good guess! My word contains your letter!
The letters you have guessed so far are: R
Here is your word so far: S--S----

Enter a new letter: z
Sorry! That letter is not in the chosen word!
The letters you have guessed so far are: R Z
Here is your word so far: S--S----

Enter a new letter: E
Good guess! My word contains your letter!
The letters you have guessed so far are: R Z
Here is your word so far: S--S---E

Enter a new letter: i
Good guess! My word contains your letter!
The letters you have guessed so far are: R Z
Here is your word so far: S--S-I-E

Enter a new letter: t
Good guess! My word contains your letter!
The letters you have guessed so far are: R Z
Here is your word so far: S--STI-E

Enter a new letter: o
Good guess! My word contains your letter!
The letters you have guessed so far are: R Z
Here is your word so far: SO-STI-E

Enter a new letter: L
Good guess! My word contains your letter!
The letters you have guessed so far are: R Z
Here is your word so far: SOLSTI-E

Enter a new letter: c
Good guess! My word contains your letter!
The letters you have guessed so far are: R Z
Congratulations! You win!
The word was: SOLSTICE

Play again?? (y/n) y







Explanation / Answer

Must work in C environment Program Description: Using the program earlier, write