Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that tests your ESP (extrasensory perception). The program should randomly select the name of a color from the following list of words:

Write a program that tests your ESP (extrasensory perception). The program should randomly select the name of a color from the following list of words:

Red; Green, Blue, Orange, Yellow

To select a word from the list, the program can generate a random number. For example, if the number is 0, the selected word is Red; if the number is 1, the selected word is Green; and so forth.

Next the program should ask the user to enter a color that the computer has selected. Check the user input for validity .After the user entered his or her guess (valid) , the program should display the name of the randomly selected color. The program should repeat 10 times and then display the number of times the user correctly guesses the selected color. Be sure to modularize the program into methods that perform each major task.

//Main method--> calls functions

public static void main(String[] args){

}

/**

computerChoice method

@return The computer's choice of "red, green", blue, or "orange".

*/

public static String computerChoice(){

}

/**

userChoice method

@return The user's choice of "red, green", blue, or "orange".

*/

public static String userChoice(){

}

/**

isValidChoice method

@param choice A string holding the user's choice.

@return true if the choice is valid, false otherwise.

*/

public static boolean isValidChoice(String choice){

}

/**

The determineWinner method displays the winner.

@param computer The computer's choice.

@param user The user's choice.

*/

public static void determineWinner(String computer, String user){

}

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_2

Step: 3

blur-text-image_3

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

Explain the focus of behavioral finance.

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago