Assignemnt #39
Code
/// Name: Sam Wilson
/// Period: 6
/// Program Name: twoquestions
/// File Name: twoquestions.java
/// Date Finished: 10/18/2015
import java.util.Scanner;
public class twoquestions
{
public static void main( String[] args )
{
Scanner ask = new Scanner(System.in);
String answer, type, size;
answer= "";
System.out.println(" WELCOME TO THE TWO QUESTIONS GAME");
System.out.println("Think of an object/animal and I'll try to guess it");
System.out.println();
System.out.println("Question 1) Is it animal, vegetable, or mineral?");
System.out.print("> ");
type = ask.next();
System.out.println("Question 2) Is it bigger than a breadbox?");
System.out.print("> ");
size = ask.next();
if (type == ("animal"))
{
if (size == ("no") || size == ("nah"))
{
answer = "mouse";
}
else if (size == ("yes"))
{
answer = "elephant";
}
}
else if (type == ("vegetable"))
{
if (size == ("no") || size == ("nah"))
{
answer = "POTATOS";
}
else if (size== ("yes"))
{
answer = "Pumpkins";
}
}
else if (type == ("mineral"))
{
if (size == ("no") || size == ("nah"))
{
answer = "Coals";
}
else if (size == ("yes"))
{
answer = "Potassium";
}
}
else
{
System.out.println("wut?");
}
System.out.println( "My guess is that you are thinking of a " + answer + "." );
System.out.println( "You win my knowledge isn't extensive enough" );
}
}
Picture of the output