public class RoundTwoDecimalPlaces{ public static void main(String[] args) { float num = 2.954165f; float round = Round(num,2); System.out.println("Rounded data: " + round); } public static float Round(float Rval, int Rpl) { float p = (float)Math.pow(10,Rpl); Rval = Rval * p; float tmp = Math.round(Rval); return (float)tmp/p; } }