Assignment #44

Code

    /// Name: Jonathan Stine
    /// Period: 5
    /// Program Name: Twenty Questions... Well, Actually Just Two
    /// File Name: TwentyQuestionsOrTwo.java
    /// Date Finished: 1/19/16
    
    import java.util.Scanner;
    
    public class TwentyQuestionsOrTwo {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            
            String type, answer;
            
            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( "> " );
            type = keyboard.next();
            System.out.println();
            
            System.out.println( "Is it bigger than a breadbox?" );
            System.out.print( "> ");
            answer = keyboard.next();
            System.out.println();
            
            if ( type.equals("animal") && answer.equals("yes") ) {
                System.out.println( "Is it a Moose?" );
                
            }
            
            else if ( type.equals("animal") && answer.equals("no") ) {
                System.out.println( "Is it a sparrow?" );
                
            }
            
            else if ( type.equals("vegetable") && answer.equals("yes") ) {
                System.out.println( "Is it a pumpkin?" );
               
            }
            
            else if ( type.equals("vegetable") && answer.equals("no") ) {
                System.out.println( "It's a Blueberry!" );
                
            }
            
            else if ( type.equals("mineral") && answer.equals("yes") ) {
                System.out.println( "It must be a large boulder!" );
               
            }
            
            else if ( type.equals("mineral") && answer.equals("no") ) {
                System.out.println( "It's a bismuth crystal" );
                
            }
            
            else {
                System.out.println( "you're incompetent and can't follow basic directions!" );
            }
            
        }
    }
    
 
    

Code Output