• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

send the formula from another place

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everybody!

I hope that all you will be fine. My Question is with reference of java.

I want to make formula syntax in another place and it will go in backend process and execute. for example:

public static void main(String args[])
{
try
{
int myResult = myFormula("(a * b)/c");
System.out.println(myResult);

}

}

public int myFormul(String Str_Variable)
{
int a = 32, b = 20, c = 2,result = 0;
try
{

result = Str_Variable;
return result;

}
}


How is it possible in java? please write any example for it.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Muhammad,
you should be aware that cross-posting between forums is not considered good manner. Please be careful the next time
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you need is an expression evaluator, which evaluates an expression given as a string with respect to variables you have in your code. One evaluator I like is JEP, which has the benefit of being free.
reply
    Bookmark Topic Watch Topic
  • New Topic