Assignment #44 and Forty-First Program
Code
/// Name: Georgi Atanasov
/// Period: 5
/// Program Name: Twenty Questions... well, actually just Two
/// File Name: TwoQuestions.java
/// Date Finished: 12/1/2015
import java.util.Scanner;
public class TwoQuestions
{
public static void main(String[] args)
{
String answer1, answer2;
Scanner keyboard = new Scanner(System.in);
System.out.println("TWO QUESTIONS!");
System.out.println("Think of an object, and I'll try to guess it.");
System.out.println();
System.out.println("Question 1) Is it an animal, toy, or rock?");
answer1 = keyboard.next();
System.out.println();
System.out.println("Question 2) Is it bigger than a guy's ego?");
answer2 = keyboard.next();
System.out.println();
if ( answer1.equals("animal") && answer2.equals("yes") )
{
System.out.println("My guess is that you are thinking of a moose.");
}
else if ( answer1.equals("animal") && answer2.equals("no") )
{
System.out.println("My guess is that you are thinking of a squirrel.");
}
else if ( answer1.equals("toy") && answer2.equals("yes") )
{
System.out.println("My guess is that you are thinking of a ball.");
}
else if ( answer1.equals("toy") && answer2.equals("no") )
{
System.out.println("My guess is that you are thinking of a scar.");
}
else if ( answer1.equals("rock") && answer2.equals("yes") )
{
System.out.println("My guess is that you are thinking of a rock.");
}
else if ( answer1.equals("rock") && answer2.equals("no") )
{
System.out.println("My guess is that you are thinking of a sandwich.");
}
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
}
Picture of the output