Assignemnt #44
Code
/// Name: Holden Ganch
/// Period: 7
/// Program Name: Fourty Fourth Program
/// File Name: Question.java
/// Date Finished: 11/4/2015
import java.util.Scanner;
class Question{
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String Q1, Q2, 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(">");
Q1 = keyboard.next();
System.out.println("");
System.out.println("Question 2.) Is it bigger than a breadbox?");
System.out.print(">");
Q2 = keyboard.next();
System.out.println("");
if (Q1.equals("animal"))
{
if (Q2.equals("no"))
{
answer = "dog";
}
else if (Q2.equals("yes"))
{
answer = "cat";
}
}
else if (Q1.equals("vegetable"))
{
if (Q2.equals("no"))
{
answer = "carrot";
}
else if (Q2.equals("yes"))
{
answer = "cabbage";
}
}
else if (Q1.equals("mineral"))
{
if (Q2.equals("no"))
{
answer = "ruby";
}
else if (Q2.equals("yes"))
{
answer = "diamond";
}
}
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 + ".");
}
}
Picture of the output