File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes String maths Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "String maths" Watch "String maths" New topic
Author

String maths

Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

I want the user to input some text ie "2 * 2 / 4 + 1" and the program to do the maths. Is there any open source code to do this or do I need to construct a series of case conditions


Jesus lives
john guthrie
Ranch Hand

Joined: Aug 05, 2002
Posts: 124
you might look at ANTLR vice a series of case conditions
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
I recently replied a post like this. I that case I suggested the use of BeanShell. It is an open source scripting language and it comes with an expression evaluator. You simply pass an String containg the expression and get the result.

Another option would be to use the new scripting powers of JDK6. Take a look at it.

I hope this helps!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: String maths
 
Similar Threads
Java does not seem to calculate doubles accurately
Maths behind Programming Languages
Other Shuffling question
Using forEach to display values from a Map
MS Math