Problem 4 Write a program called p4.py. Fill in the rest of the program, making use of the functions above, so that it does the following: 1. prompts the user to guess a character 2. validates the input. If input is invalid, then a message indicating so should be printed and the user should be prompted again. 3. Check if the character is in the word and print the word where only the guessed character is revealed, the rest of the letters should be replaced by underscores. 4. If the character is not in the word, then the number of incorrect guesses should be incremented 5. the hangman should be printed to reflect the number of incorrect guesses 6. the program should infinitely prompt the user to guess a character (repeating steps 1-5) until either the user enters 'quit' or the number of incorrect guesses reaches 6

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 8SA: What does function sqrt do? Which header file must be included to use the function sqrt? (3)
icon
Related questions
Question
NEXIGO
Tutorial 5-81 ( x
B Tutorial 5 recording (by TA Alex
O Tutorial 5 - Merge COMP1005A: X
G Write a function called print han
content/82886/viewContent/2138118/View
Problem 4
Write a program called p4.py. Fill in the rest of the program, making use of the functions above,
so that it does the following:
1. prompts the user to guess a character
2. validates the input. If input is invalid, then a message indicating so should be printed and
the user should be prompted again.
3. Check if the character is in the word and print the word where only the guessed
character is revealed, the rest of the letters should be replaced by underscores.
4. If the character is not in the word, then the number of incorrect guesses should be
incremented
5. the hangman should be printed to reflect the number of incorrect guesses
6. the program should infinitely prompt the user to guess a character (repeating steps 1-5)
until either the user enters 'quit' or the number of incorrect guesses reaches 6
Sample output -1:
Guess a letter: 5
Invalid input, please try again.
Guess a letter: A
a_a
Guess a letter:
Guess a letter:
Guess a letter: k
Guess a letter: quit
The word was 'koala
Goodbye
3
16
Transcribed Image Text:NEXIGO Tutorial 5-81 ( x B Tutorial 5 recording (by TA Alex O Tutorial 5 - Merge COMP1005A: X G Write a function called print han content/82886/viewContent/2138118/View Problem 4 Write a program called p4.py. Fill in the rest of the program, making use of the functions above, so that it does the following: 1. prompts the user to guess a character 2. validates the input. If input is invalid, then a message indicating so should be printed and the user should be prompted again. 3. Check if the character is in the word and print the word where only the guessed character is revealed, the rest of the letters should be replaced by underscores. 4. If the character is not in the word, then the number of incorrect guesses should be incremented 5. the hangman should be printed to reflect the number of incorrect guesses 6. the program should infinitely prompt the user to guess a character (repeating steps 1-5) until either the user enters 'quit' or the number of incorrect guesses reaches 6 Sample output -1: Guess a letter: 5 Invalid input, please try again. Guess a letter: A a_a Guess a letter: Guess a letter: Guess a letter: k Guess a letter: quit The word was 'koala Goodbye 3 16
Tutorial 5- B1 ( X
B Tutorial 5 recording (by TA Alex x
B Tutorial 5 - Merge COMP1005A: X
G Write a function called print han
content/82886/viewContent/2138118/View
Sample output - 2:
Guess a letter:
Gueas a letter:
Guess a letter:
Guess a letter:
kk_
Guess a letter:
Guess a letter:
kk_
Guess a letter: quit
The word was 'quokka
Goodbye
Sample output - 3:
Guess a letter: A
Guess a letter:
Guess a letter: u
Guess a letter:
Transcribed Image Text:Tutorial 5- B1 ( X B Tutorial 5 recording (by TA Alex x B Tutorial 5 - Merge COMP1005A: X G Write a function called print han content/82886/viewContent/2138118/View Sample output - 2: Guess a letter: Gueas a letter: Guess a letter: Guess a letter: kk_ Guess a letter: Guess a letter: kk_ Guess a letter: quit The word was 'quokka Goodbye Sample output - 3: Guess a letter: A Guess a letter: Guess a letter: u Guess a letter:
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning