Assignment #44 and TwoQuestions
Code
/// Name: Jason Kim
/// Period: 7
/// Program Name: TwoQuestions
/// File Name: TwoQuestions.java
/// Date Finished:10/9/15
import java.util.Scanner;
public class TwoQuestions
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
String Q1, Q2, object;
System.out.println("TWO QUESTIONS!");
System.out.println("Think of an object, and I'll try to guess it.");
System.out.println();
System.out.print("Question 1) Is it animal, vegetable, or mineral?\n> ");
Q1 = keyboard.next();
System.out.print("\nQuestion 2) Is it bigger than a breadbox?\n> ");
Q2 = keyboard.next();
if (Q1.equals("animal"))
{
if(Q2.equals("yes"))
{
object = "moose";
}
else
{
object = "squirrel";
}
}
else if (Q1.equals("vegetable"))
{
if(Q2.equals("yes"))
{
object = "watermelon";
}
else
{
object = "carrot";
}
}
else
{
if(Q2.equals("yes"))
{
object = "Camaro";
}
else
{
object = "paper clip";
}
}
System.out.println("\nMy guess is that you are thinking of a " + object + ".");
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
}
Picture of the output