public decimal Calculate(string str) { ShuntingYard sy = new ShuntingYard(); PostFixEvaluator pfe = new PostFixEvaluator(); return(Math.Round(pfe.Evaluate(sy.InfixToPostfix(str)), 2)); }
public double CALCULATE(string[] formula, int ID_NhanVien, DateTime date) { Parse p = new Parse(formula, ID_NhanVien, date); List <Element> e = p.PARSE; InfixToPostfix i = new InfixToPostfix(); e = i.ConvertFromInfixToPostFix(e); PostFixEvaluator pfe = new PostFixEvaluator(); if (e.Count == 2 && (e[1].ToString() == "+" || e[1].ToString() == "-")) { this.Value = (double)Double.Parse(formula[0]); } else { this.Value = pfe.Evaluate(e); } return(Value); }