Assignment #44 and Two Questions
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Two Questions
/// File Name: TwoQuestions.java
/// Date Finished: 9/29/2015
import java.util.Scanner;
public class TwoQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String answer1;
String answer2;
answer2 = " ";
System.out.println( "TWO QUESTIONS!" );
System.out.println( "Think of an object, and I'll try to guess it." );
System.out.println( "Question 1) Is it animal, vegetable, or mineral?" );
System.out.print( "> " );
answer1 = keyboard.next();
if ( answer1.equals("animal") )
{
System.out.println( "Question 2) Is it bigger than a breadbox?" );
System.out.print( "> " );
answer2 = keyboard.next();
if ( answer2.equals("yes") )
{
System.out.println( "My guess is that you are thinking of a bear." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else
{
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 ( answer1.equals("vegetable") )
{
System.out.println( "Question 2) Is it bigger than a breadbox?" );
System.out.print( "> " );
answer2 = keyboard.next();
if ( answer2.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( "My guess is that you are thinking of a potato." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
}
else
{
System.out.println( "Question 2) Is it bigger than a breadbox?" );
System.out.print( "> " );
answer2 = keyboard.next();
if ( answer2.equals("yes") )
{
System.out.println( "My guess is that you are thinking of a car." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else
{
System.out.println( "My guess is that you are thinking of a pencil." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
}
}
}
Picture of the output