0

I'm trying to round a String.ValueOf to the nearest whole number. Any idea how to get String.valueOf(result) to the nearest whole number.

public void onClick(View v) {
       double result =0;
       double result1 =0; 
       double a = Double.parseDouble(weightEntered.getText().toString().trim());
       double b = 2.2;
    if(v == button_convert)
    {
        if(lbs_kg.isChecked() == true) {
            result = (a / b);
            String str = String.valueOf(result);
            t1.setText(str);
        }
Ryan159
  • 109
  • 8

1 Answers1

2
String str = String.valueOf(Math.round(result));
Gorio
  • 1,606
  • 2
  • 19
  • 32