Assignment #44 and Twenty Questions
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Twenty Questions
/// File Name: TwentyQuestions.java
/// Date Finished: 11/4/2015/
import java.util.*;
public class TwentyQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String answerOne, answerTwo;
System.out.println("Think of an object and I'll try to guess it.");
System.out.println("Question 1 - Is it an animal, vegetable, or mineral?");
answerOne = keyboard.next();
System.out.println("");
System.out.println("Question 2 - Is it bigger than a breadbox?");
answerTwo = keyboard.next();
if (answerOne.equals("animal") && answerTwo.equals("yes"))
{
System.out.println("You are thinking of a moose!");
}
else if (answerOne.equals("animal") && answerTwo.equals("no"))
{
System.out.println("You are thinking of a squirrel");
}
else if (answerOne.equals("mineral") && answerTwo.equals("yes"))
{
System.out.println("You are thinking of a Camaro");
}
else if (answerOne.equals("mineral") && answerTwo.equals("no"))
{
System.out.println("You are thinking of a paper clip");
}
else if (answerOne.equals("vegetable") && answerTwo.equals("yes"))
{
System.out.println("You are thinking of a watermelon");
}
else if (answerOne.equals("vegetable") && answerTwo.equals("no"))
{
System.out.println("You are thinking of a carrot");
}
else
{
System.out.println("ERROR!! NO CAPS & SPELL CORRECTLY. ");
}
}
}
Picture of the output