retain two decimal digits.
1 package kju.o; 2 import static kju.print.Printer.*; 3 import java.text.*; 4 class MathDemo 5 { 6 public static void main(String[] args) 7 { 8 double d = 1.2458; 9 println(round(d)); //prints:1.25 10 } 11 12 static String round(double d) 13 { 14 DecimalFormat nf = new DecimalFormat("#.00"); 15 return nf.format(d); //retain two decimal digits. 16 } 17 }