Wrong value when converting Celsius/Fahrenheit
<p>This is a basic unit conversion application.</p>

<p>I just have finished coding and everything works fine except the Fahrenheit and Celsius calculation. The formula is right, but don't know why.</p>

<p>Here is Activity.Java</p>

<pre><code>package arirang.unit.converter;

import java.text.DecimalFormat;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.EditText;
import android.widget.TextView;


public class BasicUnitConverterActivity extends Activity {

EditText val3;
String val2;
int val1;
String forResult;
Spinner Type;


/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Spinner spinner1 = (Spinner) findViewById(R.id.Spinner1);
    ArrayAdapter adapter1 = ArrayAdapter.createFromResource(
            this, R.array.UnitList, android.R.layout.simple_spinner_item);
    adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(adapter1); 
}   

private String changeFormat(Double dbResult) {
    String result;

    DecimalFormat format = new DecimalFormat();
    result = format.format(dbResult);
    return result;
}



public void converter(View View) {


    EditText val3 = (EditText)findViewById(R.id.BeforeBox);
    String val2 = val3.getText().toString();
    if(val2.length() &gt;0){

    val1 = Integer.parseInt(val2); 
    Type = (Spinner)findViewById(R.id.Spinner1);

    double dbResult = 0;

    if(Type.getSelectedItem().toString().equals("meter to inch"))
    {
        dbResult = val1 * 39.3700787 ;
    }

    else if(Type.getSelectedItem().toString().equals("meter to feet"))
    {
        dbResult = val1 * 3.2808399;
    }

    else if(Type.getSelectedItem().toString().equals("feet to inch"))
    {
        dbResult = val1 * 12;
    }

    else if(Type.getSelectedItem().toString().equals("feet to meter"))
    {
        dbResult = val1 / 3.2808399;
    }

    else if(Type.getSelectedItem().toString().equals("inch to meter"))
    {
        dbResult = val1 / 39.3700787 ;
    }

    else if(Type.getSelectedItem().toString().equals("inch to feet"))
    {
        dbResult = val1 / 12;
    }

    else if(Type.getSelectedItem().toString().equals("kilogram to pound"))
    {
        dbResult = val1 * 2.20462262;
    }

    else if(Type.getSelectedItem().toString().equals("pound to kilogram"))
    {
        dbResult = val1 / 2.20462262;
    }

    else if(Type.getSelectedItem().toString().equals("Fahrenheit to Celsius"))
    {
        dbResult=(val1 - 32) * (5 / 9);
    }

    else if(Type.getSelectedItem().toString().equals("Celsius to Fahrenheit"))
    {
        dbResult = (val1 * (9 / 5)) + 32;
    }

    forResult = changeFormat(dbResult);

    TextView AfterBox = (TextView)findViewById(R.id.AfterBox);
    AfterBox.setText(forResult);
    }
}

}
</code></pre>
