If statement part 2 #47 (Annoying questions)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name: Two More Questions
/// File Name: TwoMoreQuestions.java
/// Date Finished: 11/2/2015
import java.util.Scanner;
public class TwoMoreQuestions {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String choice1, choice2, result = "";
System.out.print("Does it stay \"inside\", \"outside\", or \"both\"? ");
choice1 = input.nextLine();
System.out.print("Is it a living thing? \"Yes\" or \"no\"? ");
choice2 = input.nextLine();
if (choice1.equalsIgnoreCase("inside") && choice2.equalsIgnoreCase("yes")) {
result = "houseplant";
}
if (choice1.equalsIgnoreCase("inside") && choice2.equalsIgnoreCase("no")) {
result = "shower curtain";
}
if (choice1.equalsIgnoreCase("outside") && choice2.equalsIgnoreCase("yes")) {
result = "bison";
}
if (choice1.equalsIgnoreCase("outside") && choice2.equalsIgnoreCase("no")) {
result = "billboard";
}
if (choice1.equalsIgnoreCase("both") && choice2.equalsIgnoreCase("yes")) {
result = "dog";
}
if (choice1.equalsIgnoreCase("both") && choice2.equalsIgnoreCase("no")) {
result = "cell phone";
}
System.out.println("\nYou were probably thinking of a " + result + ".");
}
}
Picture of the output