Assignemnt #44 and Twenty Questions...Na Just Two
Code
/// Name: Tristan Chung
/// Period: 5
/// Program Name: Two Questions
/// File Name: TwoQuestions.java
/// Date Finished: 11/3/2015
import java.util.Scanner;
public class TwoQuestions
{
public static void main( String[] args )
{
String q1, q2;
Scanner keyboard = new Scanner(System.in);
System.out.println("Question 1) Is it a 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();
if (q1.equals("animal"))
{
if (q2.equals("yes"))
{
System.out.println(" My guess is that you are thinking of a dog.");
System.out.println("But if Im wrong... then whatever.");
}
else if (q2.equals("no"))
{
System.out.println(" My guess is that you are thinking of a chincilla.");
System.out.println("But if Im wrong... then whatever.");
}
}
else if (q1.equals("vegetable"))
{
if (q2.equals("yes"))
{
System.out.println(" My guess is that you are thinking of a watermelon.");
System.out.println("But if Im wrong... then whatever.");
}
else if (q2.equals("no"))
{
System.out.println(" My guess is that you are thinking of cucumber.");
System.out.println("But if Im wrong... then whatever.");
}
}
else if (q1.equals("mineral"))
{
if (q2.equals("yes"))
{
System.out.println(" My guess is that you are thinking of a volcanoe.");
System.out.println("But if Im wrong... then whatever.");
}
else if (q2.equals("no"))
{
System.out.println(" My guess is that you are thinking of vitamin.");
System.out.println("But if Im wrong... then whatever.");
}
}
else
{
System.out.println(" You answered the questions incorrectly please try again.");
}
}
}
Picture of the output