Assignment #44 Twenty Questions Na Just 2
Code
/// Name: Lacey Reese
/// Period: 5
/// Program Name: TwentyQuestionsNaJust2
/// File Name: TwentyQuestionsNaJust2.java
/// Date Finished 11/6/2015
import java.util.Scanner;
public class TwentyQuestionsNaJust2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String Answer="";
String Size="";
String Type="";
System.out.println( " TWO QUESTIONS! ") ;
System.out.println( " Think if an object, and I'll try to guess it " );
System.out.println();
System.out.println ( " Question 1) Is it an animal, vegetable or mineral? " );
System.out.println ( " > " );
Type=keyboard.next();
System.out.println ( " Question 2 ) Is it bigger than a breadbox? " ) ;
System.out.println ( " > " );
Size=keyboard.next();
if (Type.equals("vegetable")) {
if (Size.equals( "yes")){
Answer= " My guess is that you are thinking of a watermelon. " ;
} else {
Answer= " My guess is that you are thinking of a carrot. " ;
}
} else if ( Type.equals("animal")) {
if ( Size.equals( "yes" )){
Answer= " My guess is that you are thinking of a moose " ;
} else {
Answer=" My guess is that you are thinking of a squirell " ;
}
} else if ( Type.equals("mineral")) {
if ( Size.equals( "yes" )){
Answer= " My guess is that you are thinking of a Camaro " ;
} else {
Answer=" My guess is that you are thinking of a paper clip " ;
}
} else {
Answer=" Why am I here???? ";
}
System.out.println(Answer);
System.out.println( " I would ask you if I'm right, but I don't actually care. " );
}
}
Picture of the output
//