import org.vcssl.nano.VnanoEngine;
import org.vcssl.nano.VnanoException;
import java.util.Map;
import java.util.HashMap;
import java.util.Scanner;
public class ExampleApp2 {
public static void main(String[] args) throws VnanoException {
// Display the result.
VnanoEngine engine = new VnanoEngine();
// Set an option, to handle all numeric literals as "float" (=double) type.
// (Useful when calculate expressions, but don't enable when run scripts.)
Map optionMap = new HashMap();
optionMap.put("EVAL_INT_LITERAL_AS_FLOAT", true);
engine.setOptionMap(optionMap);
// Get an expression from the user.
System.out.println("Input an expression, e.g.: 1.2 + 3.4 * 5.6");
Scanner scanner = new Scanner(System.in);
String expression = scanner.nextLine();
// Append ";" at the end of the expression, if it does not exist.
if (!expression.trim().endsWith(";")) {
expression += ";";
}
// Execute the inputted expression by Vnano Engine.
double result = (Double)engine.executeScript(expression);
System.out.println("result: " + result);
}
}