Question
Using JAVA code a program that is a 20 questions game. Below is an example of how the code should follow a decision tree: Coding
Using JAVA code a program that is a 20 questions game.
Below is an example of how the code should follow a decision tree:
Coding the program should follow below:
-Prompt the user with a message to "Think of a ___, press enter when ready " using a print statement.
-Then make the program pause before asking the first question.
-To do this we can simple call the scanner .next(); method that is basically asking for input for which the user will just hit enter and continue the program. This call should not save to any variable just a simple call. So for example if I had a Scanner object "input" simple type the code input.next();
-Next use a Scanner object ask questions that follow the logic of your decision tree. You'll need to use many nested if/else and if-else-if statements to do this
-Along the way make sure that String comparisons are NOT case sensitive when checking
-Here is an example of what this would look like if we only asked yeso questions.
-Once your program comes to a conclusion about the user's object, it should print out the guess and prompt the user for confirmation if the guess was correct.
-Based on the user's response to the question here, the game should either celebrate (if it guessed correctly) or lament (if incorrectly). Display an appropriate message to the user.
The following is an example of a decision tree with yeso questions. More than 5 legs? (yeso): no Delicious? (yeso): YES Star of Charlotte's Web? (yeso): yes I guess that you are thinking of a pig! Did I guess it right? yes woo hoo!! I got it right \/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