Assignment #44 Twenty Questions... well, actually just Two
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Twenty Questions... well, actually just Two
/// File Name: TwoQuestions.java
/// Date Finished: 10/15/2015
import java.util.Scanner;
public class TwoQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String type, size;
System.out.println( "TWO QUESTIONS!" );
System.out.println( "Think of an object, and I'll try to guess it." );
System.out.println();
System.out.println( "Questions 1: Is it animal, plant, or mineral?" );
System.out.print( "> " );
type = keyboard.next();
System.out.println();
if ( type.equals("animal") )
{
System.out.println( "Questions 2: Is it bigger that a breadbox?" );
System.out.print( "> " );
size = keyboard.next();
if ( size.equals("no"))
{
System.out.println();
System.out.println( "My guess is that you are thinking of a squirrel." );
}
else if ( size.equals("yes") )
{
System.out.println();
System.out.println( "My guess is that you are thinking of a moose." );
}
}
if ( type.equals("plant") )
{
System.out.println( "Questions 2: Is it bigger that a breadbox?" );
System.out.print( "> " );
size = keyboard.next();
if ( size.equals("no"))
{
System.out.println();
System.out.println( "My guess is that you are thinking of a carrot." );
}
else if ( size.equals("yes") )
{
System.out.println();
System.out.println( "My guess is that you are thinking of a watermelon." );
}
}
if ( type.equals("mineral") )
{
System.out.println( "Questions 2: Is it bigger that a breadbox?" );
System.out.print( "> " );
size = keyboard.next();
if ( size.equals("no"))
{
System.out.println();
System.out.println( "My guess is that you are thinking of a paper clip." );
}
else if ( size.equals("yes") )
{
System.out.println();
System.out.println( "My guess is that you are thinking of a Camaro." );
}
}
System.out.println( "I would ask you if I'm right, but I don't actually care" );
}
}
Picture of the output