If the code is always running the default case, then the string being passed in does not equal any of the other cases, compared as with String.equals(). Dump the value of that parameter, perhaps enclosed in angle brackets to display whitespace and/or maybe its hex representation, to see what is getting there as opposed to what you think is getting there...
Your String is not comparable with any of your cases.
The values you are passing in function does contains some vulnerable value
So, all you need is to check if you are passing correct values in functions. This can be avoided by Passing CHAR instead of STRING into function (which is good approach for +, -, / and *) ...
public int evaluateAnswerTwoOperations(char operation, int numberOne, int numberTwo)
and do rest of the comparisons.
Other Possible Solution to your problem can be:
Instead of Multiplying in Default case You must introduce another Switch case for comparing with *. And in default case Print an Error.. So if neither of case get a perfect match.. Error will be printed
Traditionally, switch was possible only for primitive types, like int, long, char, short and enum. I do not know for sure, but as far as I am not mistaken, Android does not support switch with String in the newest version either, but certainly does not support it for older versions, so, as other answers suggested, you might want to use and pass char instead of String, due to the lack of support for the operation.
However, on Java 7, switch with String is already supported. Example:
import static java.lang.System.out;
* Simple class demonstrating switch on Strings available with JDK 7.
public class StringsWithSwitchDemo
* Main executable function.
* @param arguments Command-line arguments: none expected.
public static void main(final String arguments)
final String name = arguments.length > 0
case "Dino" :
case "Neo" :
case "Gandalf" :
out.println("Lord of the Rings?");
case "Dustin" :
out.println("Inspired by Actual Events");
out.println("The Good, the Bad, and the Ugly?");