Assignemnt #44 Twenty Questions… Na Just Two
Code
///Name: Prooz Fereydouni
///Period: 7
///Project Name: TQNJT
///File Name: TQNJT.java
///Date: 10/30/2015
import java.util.Scanner;
public class TQNJT
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String answer;
int condition1=0, condition2=0;
System.out.println( "TWO QUESTIONS!");
System.out.println( "Think of an object, I'll try to guess it.");
System.out.println("");
System.out.println("Question 1) Is it animal, vegetable, or mineral?");
answer = keyboard.next();
System.out.println("");
if(answer.equals("animal"))
{
condition1 = 1;
}
if(answer.equals("vegetable"))
{
condition1 = 2;
}
if(answer.equals("mineral"))
{
condition1 = 3;
}
System.out.println("Question 2) Is it bigger than a breadbox?");
answer = keyboard.next();
System.out.println("");
if(answer.equals("yes"))
{
condition2 = 1;
}
if(answer.equals("no"))
{
condition2 = 2;
}
if(condition1 == 1 && condition2 == 1)
{
System.out.println("My guess is that you are thinking of a moose.");
}
if(condition1 == 1 && condition2 == 2)
{
System.out.println("My guess is that you are thinking of a squirrel.");
}
if(condition1 == 2 && condition2 == 1)
{
System.out.println("My guess is that you are thinking of a watermelon.");
}
if(condition1 == 2 && condition2 == 2)
{
System.out.println("My guess is that you are thinking of a carrot.");
}
if(condition1 == 3 && condition2 == 1)
{
System.out.println("My guess is that you are thinking of a Camaro.");
}
if(condition1 == 3 && condition2 == 2)
{
System.out.println("My guess is that you are thinking of a paper clip.");
}
System.out.println("I would ask you if I'm right, but I don't actully care.");
}
}
Picture of the output