Questions Game in Java First make a decision tree on paper or draw.io. This will show the
Question:
Questions Game in Java
First make a decision tree on paper or draw.io. This will show the simple flow of possible steps/consequences/chance outcomes based on what decision is made. It is a good way to map out an algorithm that contains only conditional control statements.
Decision tree example:
You need to pick a category or group of things (even at random) for the computer to guess. The computer should then ask the questions for the user to answer. Should be a combination of yes/n0, text based and number based. YOU HAVE TO INCLUDE AT LEAST 2 OF EACH.
Guidelines for questions (when all these are met the rest of the questions can be whatever type you prefer):
The decision tree should be at least 4 questions deep (for reference, the image above is 3 questions deep) 2 String values other than simple yes/no checks 2 int and/or double values o remember double values to check equality (==) should use a range double num = 2; if (num > 1.9999 && num < 2.0001) { *** code here ****} 1 comparison of at least && or || logical operators Lastly it should contain at least two questions that have more than two outcomes. For example if you ask "How many legs does it have" consider 0, 2, 4, > 4 as possible branches. The decision tree doesn't have to be binary/just two responses
Coding the game:
The game should prompt user with a message to Think of a ___, press enter when ready using a print statement. Make the program pause before asking the first question using scanner.nextLine(); method that is basically asking for input which the user will just hit enter and continue the program. This should not save to any variable just a simple call.
Ex:
Think of an animal or insect. I'll try to guess it! Press enter when ready.
Next user Scanner object to 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. Make sure String comparisons are NOT case sensitive when checking.
Ex:
More than 5 legs? (yes/no): no
Delicious? (yes/no): YES
Star of Charlotte's Web? (yes/no): yes
Once your program comes to a conclusion about the user's object, it should print out the guess and prompt the user for confirmation.
Ex:
I guess that your are thinking of a pig!
Based on response the game should celebrate if guessed correctly or lament if incorrectly.
Ex:
Did I guess it right? yes
woo hoo!! I got it right \~~/
Business Statistics
ISBN: 9780321925831
3rd Edition
Authors: Norean Sharpe, Richard Veaux, Paul Velleman