Twenty Questions... Well, Actually Just Two
Code
/// Name: Rachel Smith
/// Period: 5
/// Program Name: Twenty Questions... Well, Actually Just Two
/// File Name: TwentyQuestionsOrTwo.java
/// Date Finished: 10/27/2015
import java.util.Scanner;
public class TwentyQuestionsOrTwo {
public static void main( String[] args ) {
Scanner keyboard = new Scanner(System.in);
String type, answer;
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?" );
System.out.print( "> " );
type = keyboard.next();
System.out.println();
System.out.println( "Is it bigger than a breadbox?" );
System.out.print( "> ");
answer = keyboard.next();
System.out.println();
if ( type.equals("animal") && answer.equals("yes") ) {
System.out.println( "Is it a tiger? I love tigers." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else if ( type.equals("animal") && answer.equals("no") ) {
System.out.println( "Is it a tarantula? I saw one of those once." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else if ( type.equals("vegetable") && answer.equals("yes") ) {
System.out.println( "Is it a ginko tree? It could really be any tree but I like that one best." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else if ( type.equals("vegetable") && answer.equals("no") ) {
System.out.println( "Is it a raspberry? Don't lie." );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else if ( type.equals("mineral") && answer.equals("yes") ) {
System.out.println( "Is it a cyborg? Like in Teen Titans...?" );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else if ( type.equals("mineral") && answer.equals("no") ) {
System.out.println( "Is it a mouse? No, not a real mouse! A computer mouse!" );
System.out.println( "I would ask you if I'm right, but I don't actually care." );
}
else {
System.out.println( "You screwed up so I won't play with you." );
}
}
}
Picture of the output