The question is not clear enough, and as written does not mention anything about creating Classes. A basic approach would be to (1) create variables a, b, c, (2) populate them with values, and (3) execute the equation. Very simple.
Joined: May 14, 2008
But I have asked to create class structure with the inter-depencies for this problem. :-(
One normally writes a compiler to parse expressions. And then some code to evaluate/execute the compiled code.
In Java, you always have access to the Java compiler, so if the expressions were to be evaluated as if they were Java, you could use the compiler, and then execute the resulting class files.
Writing a compiler is fairly advanced Computer Science. I would expect a very good student to be able to do this if they graduated from a good University undergraduate program, and I would expect that all students who have a Masters of CS to be able to do it. OR at least talk about how they would do it. Actually doing it probably would take a few months.
Using the Java compiler within a Java program is an advanced technique that I would not expect most professional Java programmers to know about. But a Senior person, it would be good if they could talk about it.
Note, this has nothing to do with most standard definitions of "real time" computing
Ganesh Thanga wrote:I went explaining that we could create classes like Operators,Operands and Expression and saying that the class Expression would be having Operators and Operands and child expression.
If you want to create a program that can parse and evaluate expressions, that sounds like a good start. Think about what kinds of things there can be in an expression: operators, numbers, variables, subexpressions etc. Now think about how these things fit together. What exactly does an expression consist of? How do operators connect parts of an expression?
To give you an idea of what you could do, look for the description of "expression trees" on this page. Once you've parsed the expression into an expression tree, you can let your program do useful things with it. Here is another example.