demonic_crow
Newbie
I'm trying to figure out how to round up the total to two decimal places. The total is an EditText. I can't get it to narrow down to just two decimal places. What wrong with it? Thanks for your help.
Code:
public void macro() {
caloriesTotal = Double.parseDouble(calories.getText().toString());
total = (caloriesTotal * .20)/9;
DecimalFormat round = new DecimalFormat ("###.##");
round.format(total);
carbsTotal = (caloriesTotal * .40)/4;
proteinTotal = (caloriesTotal * .40)/4;
fat.setText(Double.toString(total));
carbs.setText(Double.toString(carbsTotal));
protein.setText(Double.toString(proteinTotal));
}