Assignment # 44 and Two Questions
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Project Name: TwoQuestions
/// File Name: TwoQuestions.java
/// Date: 11/13/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;
}
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();
}
}
}
Picture of the output