Java tutorial
//package com.java2s; import java.text.NumberFormat; public class Main { public static String getPercentage(Integer i, Integer total) { if (i == 0) { return "0%/"; } NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMaximumFractionDigits(1); return numberFormat.format((float) i / (float) total * 100) + "%/"; } }