[Java for Android App Development] [==)BULLET(==]:
Hello everyone I tried creating a simple calculator but when opening in my LWW it just force closes , so I am attaching the xmls and .java codes for your ready reference.

I am well versed in netbeans programming but new to android hence a helpful post will be really appreciated!

Bullet

MainActivity.java

package com.ptx.calcplus;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.EditText;

public class MainActivity extends Activity {
private EditText txtNum1;
private EditText txtNum2;
private EditText txtAns;
double a = Double.parseDouble(txtNum1.getText().toString()) ;
double b = Double.parseDouble(txtNum2.getText().toString());
double c=0;

public void add(double a,double b)
{
c=a+b;
txtAns.setText(""+c);
return;
}
public void sub(double a,double b)
{
c=a-b;
txtAns.setText(""+c);
return;
}
public void div(double a,double b)
{
if(b==0)
{
txtAns.setText("Number 2 can't be 0!");
}
else{
c=a/b;
txtAns.setText(""+c);
return;
}
}

public void mul(double a,double b)
{
c=a*b;
txtAns.setText(""+c);
return;
}
[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

[MENTION=439709]override[/MENTION]
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">CalcPlus</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="btnPlus">+</string>
<string name="btnSub">-</string>
<string name="btnMul">*</string>
<string name="btnDiv">/</string>
<string name="txtNum2">Enter number 2 here</string>
<string name="txtNum1">Enter number 1 here</string>
<string name="txtAns">Result</string>

</resources>

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<Button
android:id="@+id/btnMul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnSub"
android:layout_alignBottom="@+id/btnSub"
android:layout_alignParentLeft="true"
android:text="@string/btnMul"
android:onClick="mul" />

<Button
android:id="@+id/btnSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="127dp"
android:layout_toRightOf="@+id/btnMul"
android:text="@string/btnSub"
android:onClick="sub" />

<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnSub"
android:layout_alignBottom="@+id/btnSub"
android:layout_toRightOf="@+id/btnSub"
android:text="@string/btnPlus"
android:onClick="add" />

<Button
android:id="@+id/btnDiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnAdd"
android:layout_alignBottom="@+id/btnAdd"
android:layout_toRightOf="@+id/btnAdd"
android:text="@string/btnDiv"
android:onClick="div"/>

<EditText
android:id="@+id/txtNum2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/btnMul"
android:layout_alignLeft="@+id/btnMul"
android:layout_alignRight="@+id/btnDiv"
android:layout_marginBottom="90dp"
android:ems="10"
android:hint="@string/txtNum2"
android:inputType="numberDecimal" />

<EditText
android:id="@+id/txtNum1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/txtNum2"
android:layout_alignLeft="@+id/txtNum2"
android:layout_alignRight="@+id/txtNum2"
android:layout_marginBottom="39dp"
android:ems="10"
android:hint="@string/txtNum1"
android:inputType="numberDecimal" >

<requestFocus />
</EditText>

<EditText
android:id="@+id/txtAns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtNum2"
android:layout_alignRight="@+id/btnDiv"
android:layout_below="@+id/btnMul"
android:layout_marginTop="40dp"
android:ems="10"
android:enabled="false"
android:hint="@string/txtAns"
android:linksClickable="false" />

</RelativeLayout>

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ptx.calcplus"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.ptx.calcplus.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>