Assignemnt #44 Twenty Questions… Na Just Two

Code

    Name: Iaroslav Titov
    Period: 7
    Project Name: TwoQuestions
    File Name: TwoQuestions.java
    Date: 10/21/2015
    
import javax.swing.*;

public class TwoQuestions
{
    public static void main(String[] args)
    {
        byte type;
        byte size = 0;
        
        String[][] guess = { {"squirrel","carrot","paper clip"},{"moose","watermelon","Camaro"}};
        
        String name = JOptionPane.showInputDialog("Question 1) Is it animal, vegetable or mineral?");
        
        switch (name)
        {
            case "animal": type = 0;
                break;
            case "vegetable": type = 1;
                break;
            case "mineral": type = 2;
                break;
            default: type = 99;
        }
           
        if (type==99) System.out.println("WRONG INPUT!!!");
        else
        {
        	name = JOptionPane.showInputDialog("Question 2) Is it bigger than breadbox? Y/N");
        	
            switch (name)
            {
                case "N": size = 0;
                    break;
                case "Y": size = 1;
                    break;
                default: size = 99;
            }
                
            if (size!=99)
            {
                System.out.println();
                System.out.println("My guess is that you are thinking of a "+guess[size][type]+"!!!");
                System.out.println("I am so sure that I am right that I won't ask you for confirmation.");
                System.out.println();
            }
            else System.out.println("WRONG INPUT!!!");
        	
        }
    }
}


    

Picture of the output

Assignment 41 Assignment 41