I have a problem related to programming. I want to build a application that can input a formula (which will act as function in the source code) from user, on the basis of which, there are further calculations to be done.Programming Problem. How to input a formula from user?
One solutions is:
Get the formula from the user then parse it. You have to write a parser.
At run time, todays languages won't be able to get forumula and input from those variable.
I am a Software Engineer and I know you can't do it with C, C++, Java, any .Net...
Good LuckProgramming Problem. How to input a formula from user?
If you're writing a Windows app, my first instinct would be to use the Microsoft Scripting Host. Writing a formula in JavaScript or VBScript does not differ much (if at all) from writing a formula on paper. You could plug the formula into a pre-fab method (named by you, such as ';DoCalculation';, and get the result of the forumla from the script host as a variant type. You can then perform additional calculations to your heart's content.
Otherwise, if you're talking about being able to interpret a formula, interpret it, and perform some actions on it (say to factor a polynomial equation), then you'll likely need to write your own parser.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment