Assignemnt #44: Two Questions Interactive Quiz
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: Two Questions
/// File Name: TwoQuestions.java
/// Date Finished: 10/18/2015
import java.util.Scanner;
public class TwoQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String type, size, animal, vegetable, mineral, ObjectOfInterest, a, b, c;
ObjectOfInterest = "TBD";
a = "null";
b = "alsonull";
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? " );
type = keyboard.next();
if (type.equals("animal") )
{
a = "Bear";
b = "Cockroach";
}
else if (type.equals("vegetable") )
{
a = "Watermelon";
b = "Zuccini";
}
else if (type.equals("mineral") )
{
a = "Boulder";
b = "Saphire";
}
System.out.println( "Question 2) Is it bigger than a breadbox? " );
size = keyboard.next();
if (size.equals("yes") )
{
ObjectOfInterest = a;
}
else if (size.equals("no") )
{
ObjectOfInterest = b;
}
System.out.println( "You're thinking of a " + ObjectOfInterest + " ! " ) ;
}
}
Picture of the output