I am trying to make a statement that converts a string to an int according to the following:
very negative = -2
negative = -1
neutral = 0
positive= 1
very positive = 2
Here is what I have, and for some reason, whenever I call this function it returns 5000, which indicates an error:
public static int convertSentimentToInt(String sentimentString)
{
int sentimentInt;
if (sentimentString == "Very negative")
sentimentInt = -2;
else if(sentimentString == "Negative")
sentimentInt = -1;
else if(sentimentString == "Neutral")
sentimentInt = 0;
else if(sentimentString == "Positive")
sentimentInt = 1;
else if(sentimentString == "Very positive")
sentimentInt = 2;
else
sentimentInt = -5000;
return sentimentInt;
}
I know the string I am passing as a parameter is one of these options ("Very negative", "Negative", etc.) because I test it before.