Assignemnt #44 and Twenty Questions

Code


/// Name: David Shkolnikov
/// Period: 6
/// Program Name: TwentyQuestions
/// File Name: TwentyQuestions.java
/// Date Finished: 11/4/2015

import java.util.Scanner;
public class TwentyQuestions
{
    public static void main( String[] args )
    {
        String Q1, Q2, answer;
        
        answer = "";
        
        Scanner keyboard = new Scanner(System.in);
        
        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( "Question 1) Is it animal, vegetable, or mineral?" );
        System.out.print( "> " );
        Q1 = keyboard.next();
        
        System.out.println( " " );
        System.out.println( "Question 2) Is it bigger than a breadbox?" );
        System.out.print( "> " );
        Q2 = keyboard.next();
        
        System.out.println( " " );
        
        if ( Q1.equals("animal"))
        {
            if (Q2.equals("no"))
            {
                answer = "squirrel";
            }
            else if (Q2.equals("yes"))
            {
                answer = "moose";
            }
        }
        else if ( Q1.equals("vegetable"))
        {
            if (Q2.equals("no"))
            {
                answer = "carrot";
            }
            else if (Q2.equals("yes"))
            {
                answer = "watermelon";
            }
        }
        else if ( Q1.equals("mineral"))
        {
            if ( Q2.equals("no"))
            {
                answer = "paperclip";
            }
            else if ( Q2.equals("yes"))
            {
                answer = "Camaro";
            }
        }
        System.out.println("My guess is that you are thinking of a " + answer + "." );
        System.out.println("I would ask you if I'm right, but I don't actually care." );
    }
}

    

Picture of the output

Assignment 44