Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { /** * Rounds the given results to two decimal places. * * @param results */ private static void roundResults(double[] results) { for (int i = 0; i < results.length; i++) { double result = results[i]; DecimalFormat twoDForm = new DecimalFormat("#.##"); results[i] = Double.valueOf(twoDForm.format(result)); } } }