I am currently trying to write a program which rounds a “double” variable to two decimal places.
I have the method:
DecimalFormat df = new DecimalFormat("#.00");
However, when I apply the method:
double x = df.format(y-z);
I get an error telling me a “double” was expected but a “string” was found.
Any suggestions as to how to fix this?
Thanks!
Try this
The f = 100 is fro 2dp. You would use f = 10 for 1dp etc