I have these two variables
double num = 540.512 double sum = 1978.8
Then I did this expression
double total = Math.round((
DecimalFormat decimalFormat = new DecimalFormat(".#"); String result = decimalFormat.format(12.763); // --> 12.7