Write a FULL Java procedural program for a simple word guessing game. Below is an example of the required program behaviour. The bold text is user keyboard input. The player is allowed to guess one letter or the whole word incorrectly up to 5 times; each incorrect guess is called a “strike”. The program starts by displaying one full stop (’.’) for each character of the secret word. You may assume the word is hardcoded into the game, is in lower case, and is of length greater than one. In each round of the game, the game first checks if the player has reached the maxinum number of strikes; if so, the player loses and the game ends. If not, the game prints an input prompt. The player then guesses either one letter (by entering a single character) or the whole word (by entering multiple characters). If a single letter is guessed correctly, meaning the character occurs in the word, the game reveals the positions of those occurrences in the word and proceeds to the next round. If the whole word is guessed correctly, the player wins and the game ends. If either kind of guess is incorrect, the player gains a strike and the game proceeds to the next round. Your program must: • use at least one counter-controlled for-loop. • be a procedural program. (Not an object-oriented program.) • NOT use global variables. All variables should be declared as locally as possible.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a FULL Java procedural program for a simple word guessing game. Below is an example of the required program behaviour. The bold text is user keyboard input. The player is allowed to guess one letter or the whole word incorrectly up to 5 times; each incorrect guess is called a “strike”.

  • The program starts by displaying one full stop (’.’) for each character of the secret word. You may assume the word is hardcoded into the game, is in lower case, and is of length greater than one.
  • In each round of the game, the game first checks if the player has reached the maxinum number of strikes; if so, the player loses and the game ends. If not, the game prints an input prompt.
  • The player then guesses either one letter (by entering a single character) or the whole word (by entering multiple characters). If a single letter is guessed correctly, meaning the character occurs in the word, the game reveals the positions of those occurrences in the word and proceeds to the next round.
  • If the whole word is guessed correctly, the player wins and the game ends. If either kind of guess is incorrect, the player gains a strike and the game proceeds to the next round.

Your program must:

• use at least one counter-controlled for-loop.

• be a procedural program. (Not an object-oriented program.)

• NOT use global variables. All variables should be declared as locally as possible.

Secret word: .. (4 letters)
....
Guess one letter or the word: t
Sorry! Incorrect. 1/5 strike (s).
Guess one letter or the word: j
Correct! Guessed so far: j...
Guess one letter or the word: v
Correct! Guessed so far: j.v.
Guess one letter or the word: jive
Sorry! Incorrect. 2/5 strike (s).
Guess one letter or the word: java
You win!
Below is another example.
Secret word: .... (4 letters)
Guess one letter or the word: t
Sorry! Incorrect. 1/5 strike (s).
(lines omitted)
Sorry! Incorrect. 4/5 strike (s).
Guess one letter or the word: perl
You lose! The word is: java.
Transcribed Image Text:Secret word: .. (4 letters) .... Guess one letter or the word: t Sorry! Incorrect. 1/5 strike (s). Guess one letter or the word: j Correct! Guessed so far: j... Guess one letter or the word: v Correct! Guessed so far: j.v. Guess one letter or the word: jive Sorry! Incorrect. 2/5 strike (s). Guess one letter or the word: java You win! Below is another example. Secret word: .... (4 letters) Guess one letter or the word: t Sorry! Incorrect. 1/5 strike (s). (lines omitted) Sorry! Incorrect. 4/5 strike (s). Guess one letter or the word: perl You lose! The word is: java.
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY