Assignemnt #44: Twenty Questions.. well, actually just two
Code
/// Name: Cassie
/// Period: 6
/// Program Name: Twenty Questions... well, actually just Two
/// File Name: twoquestions.java
/// Date Finished: 11/13/2015
import java.util.Scanner;
class twoquestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner( System.in );
String answerOne, answerTwo;
System.out.println( "TWO QUESTIONS!" );
System.out.println( "Think of an object, and I'll try to guess it." );
System.out.println( "Question 1) Is it an animal, vegetable, or mineral?" );
System.out.print( "> " );
answerOne = keyboard.next();
if (answerOne.equals ("animal"))
{
System.out.println( " Question 2) Is it bigger than a breadbox?" );
System.out.print( "> " );
answerTwo = keyboard.next();
if (answerTwo.equals ("yes"))
{
System.out.println( "My guess is that you are thinking of a moose." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
if (answerTwo.equals ("no"))
{
System.out.println( "My guess is that you are thinking of a squirrel." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
}
if (answerOne.equals ("vegetable"))
{
System.out.println( " Question 2) Is it bigger than a breadbox?" );
System.out.print( "> " );
answerTwo = keyboard.next();
if (answerTwo.equals ("yes"))
{
System.out.println( "My guess is that you are thinking of a watermelon." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
if (answerTwo.equals ("no"))
{
System.out.println( "My guess is that you are thinking of a carrot." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
}
if (answerOne.equals ("mineral"))
{
System.out.println( " Question 2) Is it bigger than a breadbox?" );
System.out.print( "> " );
answerTwo = keyboard.next();
if (answerTwo.equals ("yes"))
{
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." );
}
if (answerTwo.equals ("no"))
{
System.out.println( "My guess is that you are thinking of a paper clip." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
}
}
}
Picture of the output