Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

word game java Problem: you are to write a java program allowing the user to play a word game. There should be two different lists

word game java

Problem: you are to write a java program allowing the user to play a word game. There should be two different lists of words: a set of misspelled words and a set of words spelled correctly.

Here are the steps to play the game:

Your program randomly selects a word from the list (it could be a word that is misspelled or a word that is spelled correctly.

The word will be displayed to the user

User needs to decide if the word is spelled correctly or not

If the users answer is correct then he/she will gain one point otherwise he/she will lose a point

Ask the user if he/she wants to play again If the answer is no, display the score

If the answer is yes go to the step 1.

How to write your program:

You can use arrays of strings to store the words. How many arrays do you need?

You need to have two files for the words: Misspelled words and correct words

Fill in you arrays by reading from the files

Use a variable to keep track of the score

The randomly selected word cannot be repeated. Therefore you need to keep track of the words already shown to the user.

Use the scanner class to interact with the user.

Use the Random class to generate random numbers to pick a word from the list. How many random numbers do you need? You need two random numbers but why?

Use while loop to repeat the game as long as the user is interested.

Requirements:

Write a method for displaying the description of your program

Write a method for filling in the array from the files

Write a method called play

Write the algorithm for this program before start coding

Provide a description of your program

You must use methods in your program

Appropriate identifier naming

Comments

Proper indentation

Follow the naming conventions

/*Sample output
The word is: Token
mis-spelled? y/n :y
Incorrect!
The word is: File
mis-spelled? y/n :y
Incorrect!
Here is the word: Ermahgerd
Mis-speeled? y/n :y
Correct!
The word is: Throws
mis-spelled? y/n :y
Incorrect!
The word is: Preceding
mis-spelled? y/n :y
Incorrect!
You've played 5 times, give someone else a turn!
You got 0 points.
Would you like to play again? y/n
fdf
Please enter "n" or "y".
fddf
Please enter "n" or "y".
y
Here is the word: Werd
Mis-speeled? y/n :y
Correct!
The word is: Numbers
mis-spelled? y/n :n
Correct!
Here is the word: Werld
Mis-speeled? y/n :y
Correct!
Here is the word: Amurica
Mis-speeled? y/n :n
Incorrect!!
Here is the word: Unicron
Mis-speeled? y/n :n
Incorrect!!
You've played 5 times, give someone else a turn!
You got 1 points.
Would you like to play again? y/n
yes
Please enter "n" or "y".
y
Here is the word: Incorect
Mis-speeled? y/n :y
Correct!
The word is: Program
mis-spelled? y/n :n
Correct!
Here is the word: Progrems
Mis-speeled? y/n :y
Correct!
Here is the word: Fiyuhl
Mis-speeled? y/n :n
Incorrect!!
The word is: Exception
mis-spelled? y/n :y
Incorrect!
You've played 5 times, give someone else a turn!
You got 1 points.
Would you like to play again? y/n
n
----jGRASP: operation complete.
*/

/*Sample output

The word is: Token

mis-spelled? y/n :y

Incorrect!

The word is: File

mis-spelled? y/n :y

Incorrect!

Here is the word: Ermahgerd

Mis-speeled? y/n :y

Correct!

The word is: Throws

mis-spelled? y/n :y

Incorrect!

The word is: Preceding

mis-spelled? y/n :y

Incorrect!

You've played 5 times, give someone else a turn!

You got 0 points.

Would you like to play again? y/n

fdf

Please enter "n" or "y".

fddf

Please enter "n" or "y".

y

Here is the word: Werd

Mis-speeled? y/n :y

Correct!

The word is: Numbers

mis-spelled? y/n :n

Correct!

Here is the word: Werld

Mis-speeled? y/n :y

Correct!

Here is the word: Amurica

Mis-speeled? y/n :n

Incorrect!!

Here is the word: Unicron

Mis-speeled? y/n :n

Incorrect!!

You've played 5 times, give someone else a turn!

You got 1 points.

Would you like to play again? y/n

yes

Please enter "n" or "y".

y

Here is the word: Incorect

Mis-speeled? y/n :y

Correct!

The word is: Program

mis-spelled? y/n :n

Correct!

Here is the word: Progrems

Mis-speeled? y/n :y

Correct!

Here is the word: Fiyuhl

Mis-speeled? y/n :n

Incorrect!!

The word is: Exception

mis-spelled? y/n :y

Incorrect!

You've played 5 times, give someone else a turn!

You got 1 points.

Would you like to play again? y/n

n /*Sample output The word is: Token mis-spelled? y/n :y Incorrect! The word is: File mis-spelled? y/n :y Incorrect! Here is the word: Ermahgerd Mis-speeled? y/n :y Correct! The word is: Throws mis-spelled? y/n :y Incorrect! The word is: Preceding mis-spelled? y/n :y Incorrect! You've played 5 times, give someone else a turn! You got 0 points. Would you like to play again? y/n fdf Please enter "n" or "y". fddf Please enter "n" or "y". y Here is the word: Werd Mis-speeled? y/n :y Correct! The word is: Numbers mis-spelled? y/n :n Correct! Here is the word: Werld Mis-speeled? y/n :y Correct! Here is the word: Amurica Mis-speeled? y/n :n Incorrect!! Here is the word: Unicron Mis-speeled? y/n :n Incorrect!! You've played 5 times, give someone else a turn! You got 1 points. Would you like to play again? y/n yes Please enter "n" or "y". y Here is the word: Incorect Mis-speeled? y/n :y Correct! The word is: Program mis-spelled? y/n :n Correct! Here is the word: Progrems Mis-speeled? y/n :y Correct! Here is the word: Fiyuhl Mis-speeled? y/n :n Incorrect!! The word is: Exception mis-spelled? y/n :y Incorrect! You've played 5 times, give someone else a turn! You got 1 points. Would you like to play again? y/n n ----jGRASP: operation complete. */

----jGRASP: operation complete.

*/

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

Data Science For Dummies

Authors: Lillian Pierson ,Jake Porway

2nd Edition

1119327636, 978-1119327639

More Books

Students also viewed these Databases questions