Assignemnt #44 and Two Questions
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Two Questions
///File Name: TwoQuestions
///Date Finished: 10/16/15
import java.util.Scanner;
public class TwoQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String type, size;
boolean animal, vegetable, mineral, yes, no;
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, vegetable, or mineral?" );
type = keyboard.next();
animal = type.equals("animal");
vegetable = type.equals("vegetable");
mineral = type.equals("mineral");
System.out.println( " " );
System.out.println( "Question 2) Is it bigger than a breadbox?" );
size = keyboard.next();
yes = size.equals("yes");
no = size.equals("no");
if ( animal && yes )
{
System.out.println( " " );
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 if ( animal && no )
{
System.out.println( " " );
System.out.println( "My guess is that you are thinking of a squirrel." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else if ( vegetable && yes )
{
System.out.println( " " );
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 if ( vegetable && no )
{
System.out.println( " " );
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 ( mineral && yes )
{
System.out.println( " " );
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 if ( mineral && no )
{
System.out.println( " " );
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
{
System.out.println( " " );
System.out.println( "Why don't you want to play" );
}
}
}
Picture of the output