Assignemnt #44 and Two Questions
Code
///name: Nick Cerdan
///period: 6
///program name: 2 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);
String type, size, answer;
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 an animal, vegetable, or mineral?");
System.out.print(">");
type = keyboard.next();
System.out.println("");
System.out.println("Question 2.) Is it bigger than a breadbox?");
System.out.print(">");
size = keyboard.next();
System.out.println("");
if (type.equals("animal"))
{
if (size.equals("no"))
{
answer = "squirrel";
}
else if (size.equals("yes"))
{
answer = "moose";
}
}
else if (type.equals("vegetable"))
{
if (size.equals("no"))
{
answer = "carrot";
}
else if (size.equals("yes"))
{
answer = "squash";
}
}
else if (type.equals("mineral"))
{
if (size.equals("no"))
{
answer = "paper clip";
}
else if (size.equals("yes"))
{
answer = "Camaro";
}
}
else
{
System.out.println("You didn't choose one of the given choices");
answer = "Error";
}
System.out.println("My guess is that you are thinking of a " + answer + ".");
}
}