Monster Database
Hey guys, I'm super new to Java and I'm just attempting to exercise my limited knowledge to retain stuff but one thing I'm struggling with is this article of coding: import java.util.Scanner; public class Monsters{ static Scanner userInput = new Scanner (System.in); public static void main (String []args){ System.out.println("What would you like to know about?"); System.out.println(" *Monsters"); String selection = (userInput.next()); if (selection.equalsIgnoreCase("Monsters")){ monsters(); } } public static void monsters(){ System.out.println("What would you like to know about Monsters?"); System.out.println(" * Where do Monsters come from?"); System.out.println(" * Where do Monsters sleep?"); System.out.println(" * Where do Monsters live?"); System.out.println(" * What do Monsters eat?"); String a = ("Where do Monsters come from?"); String b = ("Where do Monsters sleep?"); String c = ("Where do Monsters live?"); String d = ("What do Monsters eat?"); String answer =(userInput.next()); if(answer.equalsIgnoreCase(a)){ System.out.println("They come from underneath the bed!"); } if(answer.equalsIgnoreCase(b)){ System.out.println("They sleep in the closet!"); } if(answer.equalsIgnoreCase(c)){ System.out.println("In the attic!"); } if(answer.equalsIgnoreCase(d)){ System.out.println("Carrots, strangely enough."); } } } So this is where I'm at. The main method runs appropriately (It gives you the selection " *Monsters" and when you type it in, it therefore runs the Monsters method. My issue lies within the Monsters method itself in that whenever you type in "Where do Monsters come from?" it simply terminates the program instead of running the if statement. What am I doing wrong?