Assignemnt #47 Two More Questions
Code
Name: Iaroslav Titov
Period: 7
Project Name: TwoMoreQuestions
File Name: TwoMoreQuestions.java
Date: 10/21/2015
import javax.swing.*;
public class TwoMoreQuestions
{
public static void main(String[] args)
{
byte type;
byte size = 0;
String[][] guess = { {"houseplant","bison","dog"},{"shower curtain","billboard","cell phone"}};
String name = JOptionPane.showInputDialog("Question 1) Does it stay inside, outside or both?");
switch (name)
{
case "inside": type = 0;
break;
case "outside": type = 1;
break;
case "both": type = 2;
break;
default: type = 99;
}
if (type==99) System.out.println("WRONG INPUT!!!");
else
{
name = JOptionPane.showInputDialog("Question 2) Is it alive? Y/N");
switch (name)
{
case "Y": size = 0;
break;
case "N": 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