Assignemnt #44: Two Questions
Code
/// Name: Kelsey Lieberman
/// Period 5
/// Program Name: TwoQuestions
/// File Name: TwoQuestions.java
/// Date Finished: 10/29/2015
import java.util.Scanner;
public class TwoQuestions
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String type, size;
System.out.println("TWO QUESTIONS!");
System.out.println("Think of an object, and I'll try to guess what it is.");
System.out.println("Questions 1) Is it an animal, vegetable, or mineral?");
System.out.print("> ");
type = keyboard.next();
System.out.println("\nQuestions 2) Is it bigger than a breadbox?");
System.out.print("> ");
size = keyboard.next();
if (type.equals("animal"))
{
if (size.equals("no"))
{
System.out.println("\nMy guess is that you are thinking of a squirrel.");
}
else if (size.equals("yes"))
{
System.out.println("\nMy guess is that you are thinking of a moose.");
}
else
{
System.out.println("\nERROR: Please enter \"yes\" or \"no\" to Question 2.");
}
}
else if (type.equals("vegetable"))
{
if (size.equals("no"))
{
System.out.println("\nMy guess is that you are thinking of a carrot.");
}
else if (size.equals("yes"))
{
System.out.println("\nMy guess is that you are thinking of a watermelon.");
}
else
{
System.out.println("\nERROR: Please enter \"yes\" or \"no\" to Question 2.");
}
}
else if (type.equals("mineral"))
{
if (size.equals("no"))
{
System.out.println("\nMy guess is that you are thinking of a small rock.");
}
else if (size.equals("yes"))
{
System.out.println("\nMy guess is that you are thinking of a big rock.");
}
else
{
System.out.println("\nERROR: Please enter \"yes\" or \"no\" to Question 2.");
}
}
else
{
System.out.println("\nERROR: Please enter \"animal\" or \"vegetable\" or \"mineral\" to Question 1.");
}
System.out.println("I would ask you if I'm right, but I don't actually care.");
}
}
Picture of the output