Twenty questions
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
animal
vegetable
mineral </tr>
smaller than a bread box
squirrel
carrot
paper clip </tr>
bigger than a bread box
moose
watermelon
Camaro </tr> </tbody> </table>
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. </pre>
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. </pre>
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. </pre></div>