Assignment #44 Twenty Questions… Na Just Two
Code
/// Name: Matthew Lorence
/// Period: 5
/// Program Name: Twenty Questions
/// File Name: TwentyQuestions.java
/// Date Finished:12/02/15
import java.util.Scanner;
public class TwentyQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String type, size;
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 animal, vegtable, or mineral?" );
type = keyboard.next();
System.out.println();
System.out.println( "Question 2) Is it bigger than a breadbox?" );
size = keyboard.next();
System.out.println();
if (type.equals ("animal"))
{
if (size.equals ("yes"))
{
System.out.println( "My guess is that you are thinking of a cow" );
}
}
if (type.equals ("vegtable"))
{
if (size.equals ("yes"))
{
System.out.println( "My guess is that you are thinking of a pumpkin" );
}
}
if (type.equals ("mineral"))
{
if (size.equals ("yes"))
{
System.out.println( "My guess is that you are thinking of a car" );
}
}
if (type.equals ("animal"))
{
if (size.equals ("no"))
{
System.out.println( "My guess is that you are thinking of a bug" );
}
}
if (type.equals ("vegtable"))
{
if (size.equals ("no"))
{
System.out.println( "My guess is that you are thinking of a onion" );
}
}
if (type.equals ("mineral"))
{
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" );
}
}
Picture of the output