// 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;
import java.text.NumberFormat;

public class Rounding {
    private static NumberFormat nf = new DecimalFormat("#0.00");
    public static String format(double x) {
        return nf.format(((int)(x*4+0.5))/4.0);
    }
    public static void main(String[] args) {
        System.out.println(format(5.62));
        System.out.println(format(5.63));
    }
}
