Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions