How can i round of to two decimal points with last decimal point can be either 0 , or 5
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String args[]) {
String selling_price_beMod = "23.31";
double sell_price_d = Double.parseDouble(selling_price_beMod);
String selling_price = round(sell_price_d);
System.out.println(selling_price);
}
public static String round(double value) {
DecimalFormat df = new DecimalFormat("#.00");
return df.format(value);
}
}
When i run the below program the output is
23.31
In this case i want to make it display as 23.35
Please excuse if this is a wrong question and should be approached in a different way .