Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA PROGRAM:GuessAColor GuessAColor A JAVA program that matches a random color chosen by the computer. - The user must enter the name of the color
JAVA PROGRAM:GuessAColor
GuessAColor A JAVA program that matches a random color chosen by the computer. - The user must enter the name of the color - not a number that refers to a certain color. - The randomly generated number for the computer color must be converted to the appropriate name. - Ask the user how many times they want to play and print out the percentage of the time that they guess correctly. - The main() method should look like - public static void main(String[] args) \{ runGame(); \} Information on methods above: GuessAColor() - you do not code this. The no-arg constructor that Java must have. main () - see above runGame( ) - has the main loop and counter for the game getUserColor() - asks the user for the name of their color and returns it getCompColor () - takes the random integer value generated in runGame() and returns the name of the color assigned to that value checkCorrect () - passes in the user color and computer color for one guess and returns true or false printResults () - takes the boolean from checkCorrect() and prints the results for that one guess printPctCorrect(takes in the number of games and number correct and returns the final results of the percentage correct. Sample output (must be exact) How many times do you want to play? (5 is a good number) 6 Guess a color: blue, red, white, or purple blue The computer's color was white You and the computer did not match Guess a color: blue, red, white, or purple blue The computer's color was red You and the computer did not match Guess a color: blue, red, white, or purple blue The computer's color was red You and the computer did not match Guess a color: blue, red, white, or purple blue The computer's color was blue You matched the computer Guess a color: blue, red, white, or purple blue The computer's color was blue You matched the computer Guess a color: blue, red, white, or purple blue The computer's color was purple You and the computer did not match In 6 guesses, you matched the computer 2 times The percent correct was 33.3%Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started