Results 1 to 5 of 5
  1. #1
    sapina007 is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default Parsing string and simple calculation

    Hello!

    I am trying to find a .jar that has method that takes String, egg.

    "3.7+(3.12-8)^2+1"

    and returns a result of that Mathematical expression as a number (Double).

    This kind of code could be written, but I'm short on time, so is there free jar for something like this?

    Thanks!

  2. #2
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    I have found some online, and if you search enough, you could probably find it.

    You'd think they'd include this in the standard java package, but its not there.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  3. #3
    sapina007 is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default

    I have found some online, and if you search enough, you could probably find it.
    Thanks for the info. Could you post some links, please?

  4. #4
    devunion is offline Member
    Join Date
    Jun 2008
    Posts
    56
    Rep Power
    0

    Default

    JavaScript has eval method. It has no "^" operator. You can take a look at JS support here.

    In the other case you can use tools like ANTLR or JavaCC to write your own parser.
    Try Controls4J - Advanced Swing Components.

  5. #5
    sapina007 is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default

    Thank you all for participating, but I found solution on Hussam's Al-Mulhim Web Page.

Similar Threads

  1. Multi Delimeter String Parsing
    By yuriyl in forum Advanced Java
    Replies: 5
    Last Post: 07-13-2009, 03:34 PM
  2. parsing numbers in a string
    By rsoler in forum Advanced Java
    Replies: 4
    Last Post: 03-31-2009, 06:05 AM
  3. Need help with doing a calculation in Java
    By John D. in forum New To Java
    Replies: 6
    Last Post: 02-24-2009, 11:44 PM
  4. Delay on inputs during calculation
    By matt_well in forum New To Java
    Replies: 14
    Last Post: 07-26-2008, 04:17 PM
  5. Problem with Calculation ....
    By danny000 in forum New To Java
    Replies: 1
    Last Post: 04-15-2008, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •