Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program that will implement the decision tree as seen down below. You will need to write a series of nested if statements

Write a Java program that will implement the decision tree as seen down below.

You will need to write a series of nested if statements that complete the game.

Your game should: Prompt the user with a message to Think of something. Ask the user questions to follow the logic of the decision tree.

Youll need to use many nested if/if-else/ and if-else-if statements or switch statements to do this. Along the way, be sure that your String comparisons are case insensitive (e.g., you should treat YES ,yes , and Yes as the same answer to your question).

Once your program comes to a conclusion (i.e., reaches the end of a branch in the tree) about the users item, it should make its guess in the form of a question Are you thinking of a(n) XYZ? where XYZ is the item the computer has decided you're thinking of, and then prompt the user for confirmation With a simple yeso question. If the program correctly guesses the item, a message with the word correct must appear.

If the program incorrectly guesses the item, a message with the word wrong must appear.

image text in transcribedimage text in transcribedimage text in transcribed

tanger ine tree Upward branch always 'YES Does it have orange fruit? Downward branch always 'NO banana tree Is it a fruit tree? Is it deciduous? weeping alaska cedar tree Is it a weeping tree? maple tree spruce tree Does it produce cones? flowering dagwood tree Living Plant is it native to N. America? cypress tree Does it have an nclosed seed? yew Is it a living animal, living plant, or non- living thing? tomato plant Is it ound? squash plant Is it a fruit rose bush oes it have thorns? lily plant Does it have flowers carrot plant s it orange? potato plant Is it a vegetable? boxwood bush Does it have leaves? grass Upward branch always 'YES Downward branch always 'NO Does it hunt Does it fly? aracara Is it bigger than a soccer ball? emperor penguin Feathers hunt at Does it eat meat? pine siskirn Is it llow? bluejay Can you ride it? cam Is it bigger than a chair? Fur cow Does i bark? do Is it domesticated oes have feathers fur, or err Does it hibernate? bear lion Does it eat meat? Does it have stripes? chipmunk Is it a living plant, living animal, or non-living thing? whale antelope Is it bigger than a car? dolphin ammal Does it swim? Living Animal shark Does it eat meat? ownfis it bigger than a Neither have legs omodo dragon chameleon rattlesnake Is it venemous? rat snake Furniture sofa Is it made for sitting? Upwards branch always 'YES Do you sleep on it? bed Downwards branch always 'NO loveseat Is it made for sitting? table earmuffs on your s it furniture textile, or coat wearable? rug Does it go on the floor? Textile blanket oven Non-living thing Does it cook a turkey? oes blender prepare Electronic Is it a living plant, living animal, or non-living thing? keyboard Does it play music? Is it man- lamp pond Is it still? brook Is it fresh glacier sea beach Is it water based? Is it near desert Is it flat? volcano Does it have lava? bluff tanger ine tree Upward branch always 'YES Does it have orange fruit? Downward branch always 'NO banana tree Is it a fruit tree? Is it deciduous? weeping alaska cedar tree Is it a weeping tree? maple tree spruce tree Does it produce cones? flowering dagwood tree Living Plant is it native to N. America? cypress tree Does it have an nclosed seed? yew Is it a living animal, living plant, or non- living thing? tomato plant Is it ound? squash plant Is it a fruit rose bush oes it have thorns? lily plant Does it have flowers carrot plant s it orange? potato plant Is it a vegetable? boxwood bush Does it have leaves? grass Upward branch always 'YES Downward branch always 'NO Does it hunt Does it fly? aracara Is it bigger than a soccer ball? emperor penguin Feathers hunt at Does it eat meat? pine siskirn Is it llow? bluejay Can you ride it? cam Is it bigger than a chair? Fur cow Does i bark? do Is it domesticated oes have feathers fur, or err Does it hibernate? bear lion Does it eat meat? Does it have stripes? chipmunk Is it a living plant, living animal, or non-living thing? whale antelope Is it bigger than a car? dolphin ammal Does it swim? Living Animal shark Does it eat meat? ownfis it bigger than a Neither have legs omodo dragon chameleon rattlesnake Is it venemous? rat snake Furniture sofa Is it made for sitting? Upwards branch always 'YES Do you sleep on it? bed Downwards branch always 'NO loveseat Is it made for sitting? table earmuffs on your s it furniture textile, or coat wearable? rug Does it go on the floor? Textile blanket oven Non-living thing Does it cook a turkey? oes blender prepare Electronic Is it a living plant, living animal, or non-living thing? keyboard Does it play music? Is it man- lamp pond Is it still? brook Is it fresh glacier sea beach Is it water based? Is it near desert Is it flat? volcano Does it have lava? bluff

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions