Assignemnt #44 Twenty Questions... well, actually just Two
Code
///Tyler Hart
///period 5
///Twenty Questions... well, actually just Two
///Questions.java
///10/8/2015
import java.util.Scanner;
public class Questions
{
public static void main( String[] args)
{
Scanner keyboard = new Scanner(System.in);
String type, size;
System.out.println( "Is It an animal, vegetable, or mineral" );
type = keyboard.next();
if (type.equals("animal"))
{
System.out.println("Is it bigger than a breadbox? Yes or No");
size = keyboard.next();
if (size.equals("No"))
{
System.out.println("my guess is that you are thinking of a mouse.");
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
else if (size.equals("Yes"))
{
System.out.println("my guess is that you are thinking of a moose.");
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
else
{
System.out.println("please restart");
}
}
else if (type.equals("vegetable"))
{
System.out.println("Is it bigger than a breadbox? Yes or No");
size = keyboard.next();
if (size.equals("No"))
{
System.out.println("my guess is that you are thinking of a carrot.");
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
else if (size.equals("Yes"))
{
System.out.println("my guess is that you are thinking of a watermelon.");
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
else
{
System.out.println("please restart");
}
}
else if (type.equals("mineral"))
{
System.out.println("Is it bigger than a breadbox? Yes or No");
size = keyboard.next();
if (size.equals("No"))
{
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 actually care.");
}
else if (size.equals("Yes"))
{
System.out.println("my guess is that you are thinking of a Camaro.");
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
else
{
System.out.println("please restart");
}
}
else
{
System.out.println("please restart");
}
}
}
Picture of the output