Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.63 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to do mathematical calculation in java based on user input string? [closed]
  2. String EXPRESION = null;
  3.         EXPRESION = JOptionPane.showInputDialog("Please enter expresion for dy/dx");
  4.         double x = 1.4;
  5.         double y = 5;
  6.         double output = HERE IS THE PROBLEM
  7.         JOptionPane.showMessageDialog("The value is" +output);
  8.        
  9. import jscheme.JS;
  10.  
  11. String query = "(+ 10 20)";
  12. System.out.println(query + " = " + JS.eval(query));
  13.        
  14. import bsh.*;
  15.  
  16.  class Operation
  17.  {
  18.  
  19.     public static void main(String[] args)throws Exception
  20.     {
  21.         Interpreter i=new Interpreter();
  22.         int r=(Integer)i.eval(args[0]);
  23.         System.out.println(r);
  24.     }
  25. }