Null Pointer Error
public int fromRoman(String romanChar)
{
int i = 0;
int total = 0;
while (i < romanChar.length()) { <----------- THIS LINE
Any idea what this can tell me about how I could go about solving?
I know that fromRoman generally works as when I take out the method in question, it spits out an integer that I can display. But when I add this method
public double getTotal(String whattodo) {
int number1 = fromRoman(num1);
int number2 = fromRoman(num2);
if (whattodo == "*")
{
return (number1 * number2);
}
else if (whattodo == "+")
{
return (number1 + number2);
}
else if (whattodo == "/")
{
return (number1 / number2);
}
else if (whattodo == "-")
{
return (number1 - number2);
}
else
{
throw new NumberFormatException("There is no operation present.");
}
As well as this in my run method I get a null pointer at the line previously indicated.
double total = getTotal(operator);