Assignemnt #44 and Two Questions
Code
///Name: Ben Borglin
///Period: 6
///Program Name: two questions
///File Name: twoQuestions.java
///Date finished: 10/1/15
import java.util.Scanner;
public class twoQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Two Questions!");
System.out.println("Think of an object, and I'll try to guess it.");
System.out.println(" ");
String Q1, Q2, answer;
System.out.println("Question 1) Is it animal, vegetable, or mineral?");
Q1 = keyboard.next();
System.out.println(" ");
if ( Q1.equals("animal") )
{
System.out.print("Questions 2) Is it bigger than a breadbox?");
Q2 = keyboard.next();
if ( Q2.equals("yes") )
{
System.out.println("My guess is that it is a elephant");
answer = keyboard.next();
}
else if ( Q2.equals("no") )
{
System.out.println("My guess is that it is a small bird");
answer = keyboard.next();
}
else
{
System.out.println("NO!");
}
}
else if ( Q1.equals("vegetable") )
{
System.out.print("Questions 2) Is it bigger than a breadbox?");
Q2 = keyboard.next();
if ( Q2.equals("yes") )
{
System.out.println("My guess is that it is a watermelon");
answer = keyboard.next();
}
else if ( Q2.equals("no") )
{
System.out.println("My guess is that it is a carrot");
answer = keyboard.next();
}
else
{
System.out.println("NO!");
}
}
else if ( Q1.equals("mineral") )
{
System.out.print("Questions 2) Is it bigger than a breadbox?");
Q2 = keyboard.next();
if ( Q2.equals("yes") )
{
System.out.println("My guess is that it is a paper clip");
answer = keyboard.next();
}
else if ( Q2.equals("no") )
{
System.out.println("My guess is that it is a Camaro");
answer = keyboard.next();
}
else
{
System.out.println("NO!");
}
}
else
{
System.out.println("You have not chosen the right choice.");
}
}
}
Picture of the output