I'm writing a code for an assignment that has me use multiple methods in the main. The first method prints out a banner. The second method returns a string. In the second method, I'm meant to populate a string variable named productsCatalog with three different items of length 10. If the item is less than 10 letters we are meant to pad those items with spaces and then returns that string. The third method takes the string returned from the previous method and asks the user to enter an item to see if that item exists in the productsCatalog. If the items do exist in the productsCatalog then its meant to return true if not false. The first two methods in code work fine but the third only ask for the item from the user and then terminates and doesn't check if the item exists. Should I not use an if statement? Or is the problem elsewhere?
You should take a look at the logic for the third function. You seem to be expecting it to do a lot, but not giving it any relevant code to do so. To get you going, you should:
1. Review == and the "equals(Object o)" method in Java.
2. Consider: how could the method ever return anything other than "true"? You have the default at true, and then you never change the value to anything else.
3. Review some of the methods in java.lang.String.
I hope that helps.
If a chicken that is half full crosses the road, will anyone hear it?