Global variable not updating in loop()

So my programme is designed to take an input of cnnnnnn where ‘c’ is an operator (+,-,*,/) and n are integers and output the calculation of nnn c nnn. It’s also designed to take cnnn as an input, and then calculate it with the previous answer (default at 0). The cnnn works the first time round but once the loop is ran once the prevAns variable wont update to the new answer. I’m not sure what the issue is:

String inputInt;
char Operator = inputInt.charAt(0);
int intOne;
int intTwo;
int newAns;
int prevAns;
int answer;
//------------------------------------------------------------------------------


void printWelcomeMessage()
{
  Serial.println("Please enter the integer values you wish to calculate:");
}
//-------------------------------------------------------------------------------


String promptReadln()
{
  while (!Serial.available()) {};
  return Serial.readString();
}


//-------------------------------------------------------------------------------


void errorMessage()
{
  Serial.println("ERROR");
  Serial.println("");
}


//-------------------------------------------------------------------------------


void getIntOne(String inputInt)
{
  String stringIntOne = inputInt.substring(1, 4);
  intOne = stringIntOne.toInt();
}


//-------------------------------------------------------------------------------


void getIntTwo(String inputInt) {
  String stringIntTwo = inputInt.substring(4, 7);
  intTwo = stringIntTwo.toInt();
}

//-------------------------------------------------------------------------------

String temp(String inputInt) {
  if (inputInt.length() == 5){
    previousAnswer(inputInt);
  }
  else if (inputInt.length() == 8){
    whatOperator(inputInt);
  }
  else {
    errorMessage();
  }
}

//-------------------------------------------------------------------------------


void plus(String inputInt)
{
  getIntOne(inputInt);
  getIntTwo(inputInt);
  answer = intOne + intTwo;
  Serial.print("Answer: ");
  Serial.println(answer);
  return answer;
}
//-------------------------------------------------------------------------------


void minus(String inputInt)
{
  getIntOne(inputInt);
  getIntTwo(inputInt);
  answer = intOne - intTwo;
  Serial.print("Answer: ");
  Serial.println(answer);
  return answer;
}
//-------------------------------------------------------------------------------


void multiply(String inputInt)
{
  getIntOne(inputInt);
  getIntTwo(inputInt);
  answer = intOne * intTwo;
  Serial.print("Answer: ");
  Serial.println(answer);
  return answer;
}
//-------------------------------------------------------------------------------


void divide(String inputInt)
{
  getIntOne(inputInt);
  getIntTwo(inputInt);
  if (intTwo == 0)
  {
    errorMessage();
    Serial.println("");
  }
  else
  {
    answer = intOne / intTwo;
    Serial.print("Answer: ");
    Serial.println(answer);
    return answer;
  }
}
//-------------------------------------------------------------------------------



void plus2(String inputInt)
{
  getIntOne(inputInt);
  newAns = intOne + prevAns;
  Serial.print("Answer: ");
  Serial.println(newAns);
  return answer;
}
//-------------------------------------------------------------------------------


void minus2(String inputInt)
{
  getIntOne(inputInt);
  newAns = intOne - prevAns;
  Serial.print("Answer: ");
  Serial.println(newAns);
  return answer;
}
//-------------------------------------------------------------------------------


void multiply2(String inputInt)
{
  getIntOne(inputInt);
  newAns = intOne * prevAns;
  Serial.print("Answer: ");
  Serial.println(newAns);
  return answer;
}
//-------------------------------------------------------------------------------


void divide2(String inputInt)
{
  getIntOne(inputInt);
  if (intTwo == 0)
  {
    errorMessage();
    Serial.println("");
  }
  else
  {
    newAns = intOne / prevAns;
    Serial.print("Answer: ");
    Serial.println(answer);
    return answer;
  }
}

//-------------------------------------------------------------------------------

void whatOperator(String inputInt)
{
  char Operator1 = inputInt.charAt(0);


  //Serial.print("\'");
  //Serial.print(Operator);
  //Serial.println("\'");


  if (Operator1 == '+' )
  {
    plus(inputInt);
  }
  else if (Operator1 == '-' )
  {
    minus(inputInt);
  }
  else if (Operator1 == '*' )
  {
    multiply(inputInt);
  }
  else if (Operator1 == '/' )
  {
    divide(inputInt);
  }
  else
  {
    errorMessage();
  }
}

//------------------------------------------------------------------------------

void whatOperator2(String inputInt)
{
  char Operator = inputInt.charAt(0);


  //Serial.print("\'");
  //Serial.print(Operator);
  //Serial.println("\'");


  if (Operator == '+' )
  {
    plus2(inputInt);
  }
  else if (Operator == '-' )
  {
    minus2(inputInt);
  }
  else if (Operator == '*' )
  {
    multiply2(inputInt);
  }
  else if (Operator == '/' )
  {
    divide2(inputInt);
  }
  else
  {
    errorMessage();
  }
}

//-------------------------------------------------------------------------------

String getOperand(String input){
  char Operator = inputInt.charAt(0);
  return Operator;
}

//-------------------------------------------------------------------------------

int previousAnswer(String inputInt) {
  whatOperator2(inputInt);
}

//-------------------------------------------------------------------------------


void setup()
{
  Serial.begin(9600);
  prevAns = 0;
  printWelcomeMessage();
  Serial.println("");
}
//-------------------------------------------------------------------------------


void loop()
{
  inputInt = promptReadln();
  Serial.print("Input: ");
  Serial.print(inputInt);
  temp(inputInt);
  prevAns = answer;
  Serial.println("");

}

I know that it’s a bit of a mess but everything works up to now except this issue

Project.ino (5.46 KB)

Please correct your post above and add code tags around your code: [code][color=blue]// your code is here[/color][/code].

It should look like this:// your code is here (Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

  newAns = intOne + prevAns;
  Serial.print("Answer: ");
  Serial.println(newAns);
  return answer;

You calculate 'newAns' and return 'answer'. You don't set 'answer' to 'newAns'.

Both of which are global variables so I’m not sure the need to have the function return it.