Assignemnt #44 and 20 Questions... well... Two
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: Questions
/// File Name: Questions.java
/// Date Finished: 12/2/2015
import java.util.Scanner;
public class Questions {
public static void main( String[] args ) {
Scanner keyboard = new Scanner(System.in);
String firstAnswer, secondAnswer;
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 an animal, vegetable, or mineral? ");
firstAnswer = keyboard.next();
if ( firstAnswer.equals("animal") )
{
System.out.println("Question 2) Is it bigger than a breadbox? ");
secondAnswer = keyboard.next();
if (secondAnswer.equals("yes") )
{
System.out.println("My guess is that you are thinking of a moose." );
}
else if ( secondAnswer.equals("no") )
{
System.out.println( "My guess is that you are thinking of a squirrel. " );
}
else
System.out.println(" Error " );
}
else if ( firstAnswer.equals("vegetable") )
{
System.out.println("Question 2) Is it bigger than a breadbox? ");
secondAnswer = keyboard.next();
if ( secondAnswer.equals("yes") )
{
System.out.println("My guess is that you are thinking of a watermelon." );
}
else if ( secondAnswer.equals("no") )
{
System.out.println( "My guess is that you are thinking of a carrot. " );
}
else
System.out.println(" Error " );
}
else if ( firstAnswer.equals("mineral") )
{
System.out.println("Question 2) Is it bigger than a breadbox? ");
secondAnswer = keyboard.next();
if (secondAnswer.equals("yes") )
{
System.out.println("My guess is that you are thinking of a Camaro." );
}
else if ( secondAnswer.equals("no") )
{
System.out.println( "My guess is that you are thinking of a paperclip. ");
}
else
System.out.println(" Error " );
}
System.out.println( "I would ask you if I am right but I actually don't care" );
}
}
prog44.PNG