Find the regular expression in the CheckIfUserInputValid
method. You need to add your operator to the REGEX:
@"^([0-9]+[\+\-\*\/\^])+[0-9]+$")
I have added \^
to the REGEX.
Find the EvaluateRPN
method. The while loop uses this !"+-*/^"
it essentially means not an operator. I have added the ^
to this string.
Add a new case
for the new operator. For power use Math.Pow(num1,num2)
for the calculation.
Find the ConvertToRPN
method. You need to add the new operators into the precedence dictionary.
Dictionary Precedence = new Dictionary
{
{ "+", 2 }, { "-", 2 }, { "*", 4 }, { "/", 4 }, { "^", 6 }
};