Twenty Questions... well, actually just Two

Make a program which plays a simple game of 20 2 Questions. The first question should be "animal, vegetable, or mineral?" Then, the second question should be "is it bigger than a breadbox?" Then, display one of six possible responses, depending on their answers. You can choose what answers to give for each of the six possibilities.

Here's a suggestion:

size \ type animalvegetablemineral
smaller than a breadboxsquirrelcarrotpaper clip
bigger than a breadboxmoosewatermelonCamaro

You will use nested if statements to do this.

TWO QUESTIONS!
Think of an object, and I'll try to guess it.

Question 1) Is it animal, vegetable, or mineral?
> animal

Question 2) Is it bigger than a breadbox?
> no

My guess is that you are thinking of a mouse.
I would ask you if I'm right, but I don't actually care.

 

TWO QUESTIONS!
Think of an object, and I'll try to guess it.

Question 1) Is it animal, vegetable, or mineral?
> mineral

Question 2) Is it bigger than a breadbox?
> yes

My guess is that you are thinking of a truck.
I would ask you if I'm right, but I don't actually care.

 

TWO QUESTIONS!
Think of an object, and I'll try to guess it.

Question 1) Is it animal, vegetable, or mineral?
> vegetable

Question 2) Is it bigger than a breadbox?
> yes

You're thinking of a pumpkin!
I would ask you if I'm right, but I don't actually care.



©2013 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License