Question: Write code in Java Lab - Hangman Hullabaloo You are to write a program that will: 1. Read in a word from the user (while

 Write code in Java Lab - Hangman Hullabaloo You are to

Write code in Java

Lab - Hangman Hullabaloo You are to write a program that will: 1. Read in a word from the user (while the opposing player turns head). Store this word in a String called word. 2. Create a boolean array of size word. length() - You will use the boolean array to keep track of which letters should be displayed. Initially, this array should be initialized as false (this will happen by default). 3. Create a constant (final) variable that corresponds to the total number of misses a user can have before he is hung 4. Create a variable to store the number of times a user has guessed incorrectly. as 5. Create a loop that will: a. Display the puzzle. For example: if the word is "Hello", we could display the puzzle to the user ---- As letters are guessed correctly, it will begin looking like_e__o. You will do this by cycling through the boolean array. If the value at a given index is false, you will display a "_" to the screen, if that value is true, you will instead display the corresponding letter in the word (whatever is at the same index). b. Prompt the user to enter a letter, c. Check to see if this letter is in the word. i. If it is, flip the boolean value in the boolean array that corresponds to the same index as that letter in the word. ii. If it is not, increment the number of times the user has guessed wrong. d. Check to see if the user is 'hung' - if number of incorrect guesses is greater than the constant variable that corresponds to the total number of misses a user can have before being hung. e. Check to see if the user has solved the puzzle -- if so, end the game and tell the user he won! 6. If the user becomes hung, inform the user of the solution to the puzzle. [E] Make sure that a user is not penalized for inputting a capital letter instead of a lowercase letter, or vice versa. [M] Keep track of which letters have already been guessed and check to make sure that a user does not ask for the same letter twice

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!