Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING JAVA CREATE A 20 questions program like shown below: Follow the steps as intended. Part 1 - Planning out your game To plan out

USING JAVA CREATE A 20 questions program like shown below:

Follow the steps as intended.

image text in transcribedimage text in transcribed

Part 1 - Planning out your game To plan out the game you should first construct a decision tree on paper or via draw.io G A decision tree shows the simple flow of possible next 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 The following is an example of a decision tree with yeso questions. For this you need to pick a category or group of things (even at random) for the computer to guess. The computer should then ask questions for the user to answer. These questions should be a combination of yeso, text based and number based. YOU HAVE TO INCLUDE AT LEAST 2 OF EACH. These following guidelines should be followed, when all these are met the rest of the questions can be of 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 yeso checks - 2 int and/or double values - remember double values to check equality (==) should use a range - double num =2; - if (num >1.9999&& num { 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 Now that you have the decision tree complete you should use it to guide for writing a series of nested if statements that complete the game. Your game should: - 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(); ) Think of an animal or insect. I'll try to guess it! Press enter when ready. - 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. More than 5 legs? (yeso): no Delicious? (yeso): YES Star of Charlotte's Web? (yeso): 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 if the guess was correct. I guess that you are thinking of a pig! - 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. 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

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

Step: 3

blur-text-image

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

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions