Assignemnt #44

Code

/// Name: Connor Siri
/// Period: 7
/// Program Name: Question
/// File Name: Question.java
/// Date Finished: 10/13/2015
import java.util.Scanner;
class Question{

    public static void main(String[] args) {
    
    Scanner keyboard = new Scanner(System.in);
    
   String Q1, Q2, answer; 
            
            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 an 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 = "squash";
                }
            }
            
            else if (Q1.equals("mineral"))
            {
                if (Q2.equals("no"))
                {
                    answer = "paper clip";
                }
                else if (Q2.equals("yes"))
                {
                    answer = "Camaro";
                }
            }
            
            else
            {
                System.out.println("You didn't choose one of the given choices");
                answer = "Error";
            }
            
            System.out.println("My guess is that you are thinking of a " + answer + ".");
        }
    }

    

Picture of the output

Assignment1.html