Question: Lab2.1 ESP Game (50pts]: Write a Java program that tests your ESP (extrasensory perception). The program should randomly select the name of a color from

 Lab2.1 ESP Game (50pts]: Write a Java program that tests your

Lab2.1 ESP Game (50pts]: Write a Java 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, 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. The program will prompt user to enter the color (for example, enter r to represent Red, enter g to represent Green) he or she guessed by creating an input dialog box by using JOptionPane.showInputDialog() methods. After the user has entered his or her guess, the program will display the name of the randomly selected color that computer has selected to console. The program should repeat these ten times and then display the number of times the user correctly guessed the selected color to console. The output in console should look like: (Note: the following is just an example showing the format of outputs, not the actual outputs from the program): CorrectGuess No. 1 2 You Green Red Computer Red Red No Yes 10 Orange Blue No You played game 10 times, and correctly guessed the colors 3 times. The program should also write the same output (as shown above) to a text file (.txt file) named ESP_result". Lab2.1 ESP Game (50pts]: Write a Java 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, 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. The program will prompt user to enter the color (for example, enter r to represent Red, enter g to represent Green) he or she guessed by creating an input dialog box by using JOptionPane.showInputDialog() methods. After the user has entered his or her guess, the program will display the name of the randomly selected color that computer has selected to console. The program should repeat these ten times and then display the number of times the user correctly guessed the selected color to console. The output in console should look like: (Note: the following is just an example showing the format of outputs, not the actual outputs from the program): CorrectGuess No. 1 2 You Green Red Computer Red Red No Yes 10 Orange Blue No You played game 10 times, and correctly guessed the colors 3 times. The program should also write the same output (as shown above) to a text file (.txt file) named ESP_result

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!