import java.util.Scanner;
public class guessGame {
public static void main(String[] args){
String ansOne;
String ansTwo;
String result="";
Scanner sc = new Scanner(System.in);
System.out.println("TWO QUESTIONS!");
System.out.println("Think of an object and I'll try to guess it");
System.out.println("Qusetion 1) Is it a animal,vegetable or mineral? ");
ansOne = sc.next();
System.out.println("Qusetion 2) Is it bigger than a bread box");
ansTwo = sc.next();
if(ansOne == "animal" && ansTwo == "yes"){
result = "Squirrel";
}
else if( ansOne == "animal" && ansTwo == "no"){
result = "moose";
}
else if( ansOne == "Vegetable" && ansTwo == "Yes"){
result = "carrot";
}
else if( ansOne == "Vegetable" && ansTwo == "no"){
result = "Watermelon";
}
else if( ansOne == "mineral" && ansTwo == "Yes"){
result = "Paper clip";
}
else if( ansOne == "mineral" && ansTwo == "no"){
result = "Camero";
}
System.out.println("My guess is that You are thinking of a " +result);
System.out.println("I would ask you if I'm right,but I don't actually care...");
}
}
In the above code,I want to display the result. But its not been displayed, I am getting the following output:
TWO QUESTIONS! Think of an object and I'll try to guess it Qusetion 1) Is it a animal,vegetable or mineral?
vegetable Qusetion 2) Is it bigger than a bread box yes My guess is that You are thinking of a
I would ask you if I'm right,but I don't actually care...