Assignment #44 Two Questions
Code
/// Name: DeeJay Cerezo
/// Period: 7
/// Program Name: TwoQuestions
/// File Name: TwoQuestions.java
/// Date Finished: 11/18/2015
import java.util.Scanner;
class TwoQuestions
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String answer1, answer2, yes, no, a, b, c;
System.out.println("two questions");
System.out.println(" Think of an object and I'll try and guess it.");
System.out.println();
System.out.println("Question 1: Is it an animal, vegetable, or mineral?");
System.out.print(">");
answer1= keyboard.next();
System.out.println("Question 2: Is it bigger than a breadbox?");
answer2 = keyboard.next();
if ( answer1.equals("animal"))
{
a = "mouse";
b = "dragon";
}
else if ( answer1.equals("vegetable") )
{
a= "carrot";
b= "melon";
}
else if (answer1.equals("mineral"))
{
a= "dagger";
b = "longsword";
}
else
{
a= "error";
b= "error";
}
if (answer2.equals("yes") )
{ c = b;
}
else if (answer2.equals("no") )
{ c = a;}
else {c= "error";}
System.out.println( "My guess is that you are thinking of a(n) " + c + "." );
System.out.println( "I would ask if I'm right, but I don't actually care." );
}
}
Picture of the output