1

Hai all,

I am doing c#.NET application to calculate different formulas and give result to user,users can enter any formula and each formula values are stored in database like this.

alt text

After saving like this i want to calculate the result.When calculating the result,application ask values for variables.But how can i calculate with this values. Please help to retrieve each values from database and calculate the result.

Vyasdev Meledath
  • 8,926
  • 20
  • 48
  • 68
  • You need to add more details about how the formulas are described, how is operator precedence defined (parenthesis)? What should the result of the above example be? – Albin Sunnanbo Oct 11 '10 at 07:24
  • @Albin Sunnanbo:problem is that precedence not defined (parenthesis).Only save values are varible/constant and operator.Please look at image uploaded. – Vyasdev Meledath Oct 11 '10 at 07:29
  • Create a WebRequest, pass the entered formula as a query to Google and parse the result. – Winston Smith Oct 11 '10 at 07:57

1 Answers1

4

You can use Shunting-yard algorithm to convert the expression to postfix notation or to ast directly. See this answer for nice explanation: Equation (expression) parser with precedence

Community
  • 1
  • 1
Giorgi
  • 30,270
  • 13
  • 89
  • 125
  • 1
    +1: You may want to add these useful links: http://en.wikipedia.org/wiki/Shunting-yard_algorithm and http://en.wikipedia.org/wiki/Postfix_notation – Callum Rogers Oct 11 '10 at 08:18