Assignemnt #44 20 Questions
Code
///Name: Joshua Pell
///Period: 6
///Project Name: 20 Questions
///File Name: Questions.java
///Date: 10/29/2015
import java.util.Scanner;
public class Questions
{
public static void main( String[] args)
{
Scanner keyboard = new Scanner(System.in);
String thing, size;
System.out.println( "Is is an animal, vegetable, or mineral?");
thing = keyboard.next();
if (thing.equals("animal"))
{
System.out.println("Is it bigger than a breadbox?");
size = keyboard.next();
if (size.equals("no"))
{
System.out.println("My guess is that you're thinking of a squirrel.");
}
else if (size.equals("yes"))
{
System.out.println("My guess is that you're thinking of a moose.");
}
}
if (thing.equals("vegetable"))
{
System.out.println("Is it bigger than a breadbox?");
size = keyboard.next();
if (size.equals("no"))
{
System.out.println("My guess is that you're thinking of a carrot.");
}
else if (size.equals("yes"))
{
System.out.println("My guess is that you're thinking of a watermelon.");
}
}
if (thing.equals("mineral"))
{
System.out.println("Is it bigger than a breadbox?");
size = keyboard.next();
if (size.equals("no"))
{
System.out.println("My guess is that you're thinking of a paper clip.");
}
else if (size.equals("yes"))
{
System.out.println("My guess is that you're thinking of a Camaro.");
}
}
}
}
Picture of the output