Question
please use java THIS IS AN INDIVIDUAL ASSIGNMENT. COLLABORATION WITH ANOTHER STUDENT WILL BE CONSIDERED ACADEMIC DISHONESTY. For this assignment, you will create a program
please use java
THIS IS AN INDIVIDUAL ASSIGNMENT. COLLABORATION WITH ANOTHER STUDENT WILL BE CONSIDERED ACADEMIC DISHONESTY.
For this assignment, you will create a program that emulates a round of the word game GHOST.
At the beginning of the program, read the file words.txt and save the words into an array. There are 279496 words in the file. Do not read the file more than once in your program.
Ask for the number of players. Then, begin prompting players to enter a letter, one at a time. In the prompt, show the letters that have been entered so far. After the final player enters a letter, the first player goes again and so on until the game ends.
The game ends when either of two conditions occurs: 1) the letters entered form a word of at least four letters, or 2) the player enters a * to challenge the previous player. If the letters form a word of at least four letters, the last player to enter a letter loses. If a * is entered, check to see if any word begins with the sequence of letters entered so far. If so, the player who entered a * loses. Otherwise, the last player to enter a letter loses. When the game ends, output the loser and end the program.
Upload your .java file.
80% of the points for this project are based on your program working correctly. The other 20% is coding style, such as proper indentation; ask your lab instructor for details.
Enter the number of players: 3 Player 1, it's your turn. The letters are. Enter a letter or enter * to challenge. S Player 2, it's your turn. The letters are S. Enter a letter or enter * to challenge. I Player 3, it's your turn. The letters are SI. Enter a letter or enter * to challenge. G Player 1, it's your turn. The letters are SIG. Enter a letter or enter * to challenge. N SIGN is a word. Player 1 loses! Enter the number of players: 4 Player 1, it's your turn. The letters are. Enter a letter or enter * to challenge. G Player 2, it's your turn. The letters are G. Enter a letter or enter * to challenge. H Player 3, it's your turn. The letters are GH. Enter a letter or enter * to challenge. 0 Player 4, it's your turn. The letters are GHO. Enter a letter or enter * to challenge. T Player 1, it's your turn. The letters are GHOT. Enter a letter or enter to challenge. No word begins with those letters. Player 4 loses! Enter the number of players: 4 Player 1, it's your turn. The letters are. Enter a letter or enter * to challenge. A Player 2, it's your turn. The letters are A. Enter a letter or enter * to challenge. A Player 3, it's your turn. The letters are AA. Enter a letter or enter * to challenge. R Player 4, it's your turn. The letters are AAR. Enter a letter or enter * to challenge. G Player 1, it's your turn. The letters are AARG. Enter a letter or enter to challenge. AARGH begins with those letters. Player 1 loses! Enter the number of players: 3 Player 1, it's your turn. The letters are. Enter a letter or enter * to challenge. S Player 2, it's your turn. The letters are S. Enter a letter or enter * to challenge. I Player 3, it's your turn. The letters are SI. Enter a letter or enter * to challenge. G Player 1, it's your turn. The letters are SIG. Enter a letter or enter * to challenge. N SIGN is a word. Player 1 loses! Enter the number of players: 4 Player 1, it's your turn. The letters are. Enter a letter or enter * to challenge. G Player 2, it's your turn. The letters are G. Enter a letter or enter * to challenge. H Player 3, it's your turn. The letters are GH. Enter a letter or enter * to challenge. 0 Player 4, it's your turn. The letters are GHO. Enter a letter or enter * to challenge. T Player 1, it's your turn. The letters are GHOT. Enter a letter or enter to challenge. No word begins with those letters. Player 4 loses! Enter the number of players: 4 Player 1, it's your turn. The letters are. Enter a letter or enter * to challenge. A Player 2, it's your turn. The letters are A. Enter a letter or enter * to challenge. A Player 3, it's your turn. The letters are AA. Enter a letter or enter * to challenge. R Player 4, it's your turn. The letters are AAR. Enter a letter or enter * to challenge. G Player 1, it's your turn. The letters are AARG. Enter a letter or enter to challenge. AARGH begins with those letters. Player 1 loses
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started