// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.text.DecimalFormat;

public class TwoDecimals {
   public static void main(String[] args) {
      double d = 123.456;
      double d2 = ((int) (100 * d)) / 100.0;
      System.out.println(d2);
      double d3 = ((int) (100 * d + 0.5)) / 100.0;
      System.out.println(d3);
      Double dd = new Double(d);
      Double dd2 = new Double(((int) (100 * dd.doubleValue())) / 100.0);
      System.out.println(dd2);
      Double dd3 = new Double(((int) (100 * dd.doubleValue() + 0.5)) / 100.0);
      System.out.println(dd3);
      DecimalFormat fmt = new DecimalFormat("#.00");
      System.out.println(fmt.format(d));
      System.out.println(fmt.format(dd.doubleValue()));
      double d4 = 10.0;
      System.out.println(fmt.format(d4));
   }
}
