Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Java in General
is this possible in Java? Execute a string formula with variables
Winston Liek
Ranch Hand
Posts: 197
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
given a
string
pseudocode,
int y = 3;
String formula = "7*(y + 3)";
int answer = evaluate the formula substituting the value of 3 from y
is it possible to get the answer variable?
Henry Wong
author
Posts: 23951
142
I like...
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
In my opinion, the easiest way to accomplish this is to use the
Java
Scripting API (see
https://docs.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/
for more details).
The API (along with a basic JS engine) is also built-in to Java, so there is no need to install anything.
Henry
Books:
Java Threads, 3rd Edition
,
Jini in a Nutshell
, and
Java Gems (contributor)
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You could also look into the way compilers work to analyze program statement text to create program steps.
A deeper, slower, but fun exercise.
Bill
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
K&B Study Guide - Chapter 6 Self Test - Question 9
precedence prob. again..this time 4rm RHE...very urgent
operator precedence
Question errors
increasing and decreasing in loop
More...