Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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.

image text in transcribed

-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.

image text in transcribed

-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.

image text in transcribed

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

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

Discuss about training and development in India?

Answered: 1 week ago

Question

Explain the various techniques of training and development.

Answered: 1 week ago

Question

Explain the various techniques of Management Development.

Answered: 1 week ago

Question

Describe new developments in the design of pay structures. page 475

Answered: 1 week ago