Assignemnt #40 Twenty Questions
Code
///Name: JJ Deng
///Period: 6
///Program Name: Two Questions
///File Name: TwoQuestions.java
///Date Finished:
import java.util.Scanner;
public class TwoQuestions
{
public static void main( String[] args )
{
Scanner TQ = new Scanner(System.in);
String answer, type, size;
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 animal, vegetable, or mineral?");
System.out.println(">");
type = TQ.next();
System.out.println("Question 2) Is it bigger than a breadbox?");
System.out.println(">");
size = TQ.next();
if (type.equals("animal"))
{
if (size.equals("no"))
{
answer = "mouse";
}
else if (size.equals("yes"))
{
answer = "elephant";
}
}
else if (type.equals("vegetable"))
{
if (size.equals("no"))
{
answer = "POTATOS";
}
else if (size.equals("yes"))
{
answer = "Pumpkins";
}
}
else if (type.equals("mineral"))
{
if (size.equals("no"))
{
answer = "Coals";
}
else if (size.equals("yes"))
{
answer = "Potassium";
}
}
else
{
System.out.println("Ha you didn't have an answer stooopidddddddd");
}
System.out.println( "My guess is that you are thinking of a " + answer + "." );
System.out.println( "I would ask you if I'm right, but I don't actually care. " );
}
}
Picture of the output