How can I use the square root of a number that the user enters in an input box, instead of the number itself?
<p>I'm trying to make an Android app, and the feature that I'm working on right now is calculating the square root of a number entered by the user.</p>

<p>How can I take a number that the user enters in a text box, and use the square root of that number in the <code>doCalc</code> part of my program? I'm limiting the number to be an integer between 1 and 20. For example, if the user enters <code>2</code> in the input box, I want to use <code>1.41</code> in the <code>doCalc</code> method. </p>

<p>Here is my .java code:</p>

<pre><code>package learn.text;

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

public class LearntextActivity extends Activity {
    TextView text;
    EditText input;
    TextView text2;
    EditText input2;
    TextView text3;
    EditText input3;
    Button calc;
    TextView output;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        text = (TextView) findViewById(R.id.text);
        text.setText("Enter the design GPM for Chiller");
        input = (EditText) findViewById(R.id.input);
        text2 = (TextView) findViewById(R.id.text2);
        text2.setText("Enter the Square root of the actual pressure drop across the coil");
        input2 = (EditText) findViewById(R.id.input2);
        text3 = (TextView) findViewById(R.id.text3);
        text3.setText("Enter the design pressure drop of coil");
        input3 = (EditText) findViewById(R.id.input3);
        calc = (Button) findViewById(R.id.calc);
        output = (TextView) findViewById(R.id.output);
    } 
    public void doCalc (View view)  {
        double mInput = Double.parseDouble(input.getText().toString());
        double mInput2 = Double.parseDouble(input2.getText().toString());
        double mInput3 = Double.parseDouble(input3.getText().toString());

        double mOutput = (mInput*mInput2)/(mInput3);
        output.setText("GPM is" + mOutput);
    }    
}
</code></pre>

<p>Here is the .xml file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" /&gt;
    &lt;TextView android:layout_height="wrap_content" android:text="" android:layout_width="wrap_content" android:id="@+id/text"&gt;&lt;/TextView&gt;
    &lt;EditText android:layout_height="wrap_content" android:text="" android:layout_width="match_parent" android:id="@+id/input"&gt;&lt;/EditText&gt;
    &lt;TextView android:layout_height="wrap_content" android:text="" android:layout_width="wrap_content" android:id="@+id/text2"&gt;&lt;/TextView&gt;
    &lt;EditText android:layout_height="wrap_content" android:text="" android:layout_width="match_parent" android:id="@+id/input2"&gt;&lt;/EditText&gt;
    &lt;TextView android:layout_height="wrap_content" android:text="" android:layout_width="wrap_content" android:id="@+id/text3"&gt;&lt;/TextView&gt;
    &lt;EditText android:layout_height="wrap_content" android:text="" android:layout_width="match_parent" android:id="@+id/input3"&gt;&lt;/EditText&gt;

    &lt;Button android:layout_height="wrap_content" android:text="Get GPM" android:layout_width="wrap_content" android:id="@+id/calc" android:password="false" android:onClick="doCalc"&gt;&lt;/Button&gt;
    &lt;TextView android:layout_height="wrap_content" android:text="" android:layout_width="wrap_content" android:id="@+id/output"&gt;&lt;/TextView&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>Here is the manifest file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="learn.text"
    android:versionCode="1"
    android:versionName="1.0" &gt;

    &lt;uses-sdk android:minSdkVersion="10" /&gt;

    &lt;application
        android:icon="@drawable/ic_launcher" android:label="string/app_name"&gt; 
        android:label="@string/app_name" &gt;
        &lt;activity
            android:name=".LearntextActivity"
            android:label="@string/app_name" &gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;

                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
&lt;/manifest&gt;
</code></pre>
