Write a program "LetterGame.java" to play an alphabet (A to Z) guessing game between the computer and a player (you). Your program should work like the following way: There are two situations: In...

Write a program "LetterGame.java" to play an alphabet (A to Z) guessing game between the computer and a player (you). Your program should work like the following way: There are two situations: In situation 1, the computer lay out a random letter in the range (A to Z, capital only) and the player (you) tries to guess it, maximum in three guesses only. The computer must respond to each guess (response is in lower case only) by printing "correct", "before"(your guess is before the answer), or "after"(your guess is after the answer), to judge your guessing is before/after the unknown letter. In situation 2, the player lay out a letter in the range (A to Z, capital only) and asks the computer to guess. The computer tries to guess it, maximum in three times. The player must respond to each guess by telling "correct", "before", or "after" to judge the guessing is before/after the given letter. Request: 1) The program prints out good instructions when necessary. (The menu) 2) Your program asks who tries to guess. (It can be 1=you, 2-computer) 3) The program prints out how many guesses are used after finishing tries. 4) The program prints out the result of the guess is right or wrong, and print out the true letter after finishing tries. 5) The computer asks if the user wants to play again. (apply loop). Note: 1) To read in response numbers, characters and/or strings, use Scanner. 2) Apply Methods as possible as it can be. 3) For full credit, pay attention on indentations of the program and necessary remarks or comments (style of programing.) Some commands (cast) to be used: int x=(int)'A'; This command converts the letter 'A' to the corresponding number (65) as in the ASCII code. char y=(char) 66; This command converts the number 66 to a corresponding character 'B' as in the ASCII code. int num=(int)(Math.random()*1000000)% n+1 This command creates a random number 'num that is in :0
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here