Assignment #44 and Twenty Questions
Code
///Name: Tim Gibson
///Period: 6
///Project Name: Twenty Questions
///File Name: Questions.java
///Date Finished: 10/6/15
import java.util.Scanner;
public class Questions
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String q1, q2, guess;
System.out.println( "TWO QUESTIONS \nThink of an Object, and I'll try to guess it." );
System.out.println( "\nQuestion 1) Is it an animal, vegetable, or mineral?" );
q1 = keyboard.next();
System.out.println( "\nQuestion 2) Is it bigger than a breadbox? " );
q2 = keyboard.next();
if ( q1.equals("animal"))
{
if ( q2.equals("yes"))
{
guess = "Moose";
}
else
{
guess = "Mouse";
}
}
else if ( q1.equals("vegetable"))
{
if ( q2.equals("yes"))
{
guess = "Pumpkin";
}
else
{
guess = "Carrot";
}
}
else
{
if ( q2.equals("yes"))
{
guess = "Car";
}
else
{
guess = "Paper Clip";
}
}
System.out.println( "\nYou're thinking of a " + guess + "!\nI would ask you if I'm right, but I don't actually care." );
}
}
Picture of the output