posted 11 years ago
Write a program in Java that can parse a mathematical expression
String, calculate the expression, and produce a numeric result.
For example, given the string: "2.5+3*4+6/127" produce the result 8.0
Requirements: Parser
* expression can contain Integers or floatingpoint numbers
* expression can contain Operators for addition, subtraction, division
and multiplication
* parser should throw an Exception when the expression is invalid
Requirements: Solution
* Implement the solution in Java
* Compile and test the solution
* The solution should demonstrate good modularity, be selfcontained,
reusable and extensible.
* The solution should be clearly written, easy to read, documented, and
productionquality.
Requirements: quality
* This is a timed exercise and should be completed quickly, however you
should take sufficient time to produce a quality result
* A quality solution is simple, concise, complete, well documented,
readable, adaptable, reusable, testable and robust.
String, calculate the expression, and produce a numeric result.
For example, given the string: "2.5+3*4+6/127" produce the result 8.0
Requirements: Parser
* expression can contain Integers or floatingpoint numbers
* expression can contain Operators for addition, subtraction, division
and multiplication
* parser should throw an Exception when the expression is invalid
Requirements: Solution
* Implement the solution in Java
* Compile and test the solution
* The solution should demonstrate good modularity, be selfcontained,
reusable and extensible.
* The solution should be clearly written, easy to read, documented, and
productionquality.
Requirements: quality
* This is a timed exercise and should be completed quickly, however you
should take sufficient time to produce a quality result
* A quality solution is simple, concise, complete, well documented,
readable, adaptable, reusable, testable and robust.
posted 11 years ago
If I could understand it correctly, the String
"2.5+3*4+6/127"
should be parsed into individual operands and operator.
float operand1 = 2.5
char operator1 = '+'
int operand2 = 3;
char operator2 ='*'
and so on. You need to the execute the above expression which gives you the result of 8.
2.5 + (3*4) + (6/12)  7 = 8
"2.5+3*4+6/127"
should be parsed into individual operands and operator.
float operand1 = 2.5
char operator1 = '+'
int operand2 = 3;
char operator2 ='*'
and so on. You need to the execute the above expression which gives you the result of 8.
2.5 + (3*4) + (6/12)  7 = 8
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
