-2

I am doing a Web Service with JSF and WSDL/SOAP technology. How do I read a complex mathematical operation input string, looks like 53*6+8/2 from the user, and calculate it using Web Service method?

Got these methods from http://www.dneonline.com/calculator.asmx?WSDL

public int add(int intA, int intB) {
    //TODO implement this method
    throw new UnsupportedOperationException("Not implemented yet.");
}

public int subtract(int intA, int intB) {
    //TODO implement this method
    throw new UnsupportedOperationException("Not implemented yet.");
}

public int multiply(int intA, int intB) {
    //TODO implement this method
    throw new UnsupportedOperationException("Not implemented yet.");
}

public int divide(int intA, int intB) {
    //TODO implement this method
    throw new UnsupportedOperationException("Not implemented yet.");
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mavisss
  • 41
  • 3
  • 1
    You need to either write your own expression parser or use an off the shelf one. Depending on why you need this will drive the choice (eg. if homework then likely the intent is for you to do it the hard way; if for line of business application then look for existing code). – Richard Mar 27 '17 at 08:38

1 Answers1

-1

You could use javascript engine to achieve it in the simplest way. Please see Evaluating a math expression given in string form

Community
  • 1
  • 1
OTM
  • 656
  • 5
  • 8