Question: Write this program by using Java: The object of the game is for the user to guess the colors the program has chosen. The program

Write this program by using Java:

The object of the game is for the user to guess the colors the program has chosen. The program chooses six distinct colors from among ten colors. The user obviously does not know the colors the program has chosen.

The operations user can perform and the outcomes:

The user picks six colors:

The program displays a color code back to indicate the progress the user has made.

If the user guessed the exact color combination, including the positions, the result is six black colors. The game ends now with a message that the user has won and the program reveals the color selected.

If the user guessed only some colors, then the result has as many black colors as the number of direct positions matches and as many silver colors for each match that is in an incorrect position.

For example, if the program selected green, red, blue, white, orange, purple, and the user entered cyan, yellow, blue, orange, violet, red, then the program will display black, silver, silver.

User gives up: The program displays the colors selected, game ends with a message the user has lost.

User has made 20 tries: The program displays the colors selected, game ends with a message the user has lost (unless in the last try the user found the combination).

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!