Assignemnt 44 and Two Questions
Code
/// Name: Xinting Chen
/// Period: 7
/// Program Name: Two Questions
/// File Name: TwoQuestions.java
/// Date Finished: 11/19/2015
import java.util.Scanner;
public class TwoQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int type = 0;
int size = 0;
int guess = 0;
String read = "";
String 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("Quesiton 1) Is it animal, vegetable, or mineral? ");
System.out.println("<");
read = keyboard.next();
if (read.equals("animal"))
type= 1 ;
if (read.equals("vegetable"))
type= 2;
if (read.equals("mineral"))
type= 3;
System.out.println("Quesiton 2) Is it bigger than a breadbox? ");
System.out.println("<");
read = keyboard.next();
if (read.equals("yes"))
size= 1 ;
if (read.equals("no"))
size= 2;
guess = type;
if (size == 2) guess += 3;
if (guess == 1) answer = "squirrel";
if (guess == 2) answer = "carrot";
if (guess == 3) answer = "paper clip";
if (guess == 4) answer = "moose";
if (guess == 5) answer = "watermelon";
if (guess == 6) answer = "Camero";
System.out.println("My guess is that you are thinking of a " + answer + "\n I would ask you if I'm right, but I don't actually care.");
}
}
Picture of the output