title: Android calculator with single edit text displaying complete input and output
body: <p>I want to display the complete input and output of my app.  </p>
  
  <p>For example:</p>
  
  <p><code>2+2=4</code> needs to be displayed after clicking "=" in the calculator.</p>
  
  <p>My problem is that app closes unexpectedly.</p>
  
  <pre><code>package com.scientific.calculator;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ToggleButton;
  
  public class Calculator extends Activity{
  
      EditText display;
      Button btn,btnop,add,sub,mul,div;
      ToggleButton shift;
      String operator,result;
      float value=0;
      Character op = 'q';
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.calculator);
          display = (EditText)findViewById(R.id.etDisplay);
          shift = (ToggleButton)findViewById(R.id.tbShift);
      }
  
      public void set_number(View v) {
          // TODO Auto-generated method stub
          btn = (Button)findViewById(v.getId());
          result = display.getText().toString();
          display.setText(result+btn.getText().toString());
      }
  
       public void btnplusclicked(View v){
             perform(v);
             op = '+';
  
            }
  
            public void btnminusclicked(View v){
             perform(v);
               op = '-';
  
            }
            public void btndivideclicked(View v){
             perform(v);
             op = '÷';
  
            }
            public void btnmulticlicked(View v){
             perform(v);
             op = '×';
  
            }
  
            public void btnequalClicked(View v){
                evaluate();
  
            }
  
            public void perform(View v) {
                  // TODO Auto-generated method stub
                  btnop=(Button)findViewById(v.getId());
                  result=display.getText().toString();
                  operator=btnop.getText().toString();
                  display.setText(result+operator);
                 }
                    private void evaluate() {
                  // TODO Auto-generated method stub
                        value=Float.valueOf(display.getText().toString());
                  if(op == '+')
                   value=Float.valueOf(display.getText().toString())+value;
                  else if(op == '-')
                      value=Float.valueOf(display.getText().toString())-value;
                  else if(op == '/')
                      value=Float.valueOf(display.getText().toString())/value;
                  else if(op == '*')
                      value=Float.valueOf(display.getText().toString())*value;
  
                  display.setText(String.valueOf(value));
                 }
  
  
  }
  </code></pre>