Also there is an open source java library for evaluating mathematical expressions at http://zee.dev.java.net

You could use this code to write out "3.0":

String input = "1+2";
double result =...