title: Plus or minus minor glitch in my android calculator
body: <p>I have made an android calculator, and I have added the +/- button to it recently. The problems I am facing is, firstly when I use it, and press the equal button, the app crashes. Moreover as soon as I click +/- button, the digits turn into a float value, and when I type any number the number value continues after the decimal. Example: I have 200 and I press +/- the number becomes 200.0 and when I type any number it becomes 200.01. How do I overcome this problem? Can someone please let me know what are the changes required in my code? Here it is.
  Thank you. :)</p>
  
  <pre><code>    public class MainActivity extends Activity {
      Typeface font1, font2;
  
      TextView tv1;
      private EditText Scr; //textbox screen
      private float NumberBf; //Save screen before pressing button operation;
      private String Operation;
      private ButtonClickListener btnClick;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_NO_TITLE);  
          setContentView(R.layout.activity_main);
          font1=Typeface.createFromAsset(getAssets(), "digits.ttf");
          Scr=(EditText)findViewById(R.id.editText);
          Scr.setTypeface(font1);
          font2=Typeface.createFromAsset(getAssets(), "alexbrush.TTF");
          tv1=(TextView)findViewById(R.id.textView1);
          tv1.setTypeface(font2);
          Scr = (EditText) findViewById(R.id.editText);
          Scr.setEnabled(false);
          btnClick = new ButtonClickListener();
          int idList[] = {R.id.button0,R.id.button7, R.id.button1, R.id.button8,R.id.button9,R.id.button4,
                  R.id.button5,R.id.button6,R.id.button,R.id.button2,R.id.button3,R.id.buttonDot,
                  R.id.buttonMul,R.id.buttonDiv,R.id.buttonAdd,R.id.buttonSub,R.id.buttonC,
                  R.id.buttonEq, R.id.buttonSqrt, R.id.buttonsquare, R.id.buttonNp
          };
  
          for(int id:idList){
              View v = (View) findViewById(id);
              v.setOnClickListener(btnClick);
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      public void mMath(String str){
          NumberBf = Float.parseFloat(Scr.getText().toString()); //save the screen
          Operation = str; //save operation
          Scr.setText("0"); //Clear screen
      }
  
      public void getKeyboard(String str){
          String ScrCurrent = Scr.getText().toString();
          if(ScrCurrent.equals("0"))
              ScrCurrent = "";
          ScrCurrent += str;
          Scr.setText(ScrCurrent);
      }
  
      public void mResult(){
          float NumAf = Float.parseFloat(Scr.getText().toString());
          float result = 0;
          if(Operation.equals("+")){
              result = NumAf + NumberBf;
          }
          if(Operation.equals("-")){
              result = NumberBf - NumAf;
          }
          if(Operation.equals("*")){
              result = NumAf * NumberBf;
          }
          if(Operation.equals("/")){
              result = NumberBf / NumAf;
          }
          Scr.setText(String.format("%10d", result));
      }
  
      public void fnSqrt(){
          double Number = Double.parseDouble(Scr.getText().toString());
          Number = Math.sqrt(Number);
          Scr.setText(String.valueOf(Number));
      }
  
      public void fnSquare(){
          float Number1 = Float.parseFloat(Scr.getText().toString());
          Number1 = pow(Number1, 2);
          Scr.setText(String.valueOf(Number1));
      }
  
      public void fnNp(){
          float Number = Float.parseFloat(Scr.getText().toString());
          Number = Number*(-1);
          Scr.setText(String.valueOf(Number));
          }
  
      private float pow(float number1, int i) {
          return number1*number1;
      }
  
      private class ButtonClickListener implements OnClickListener{
          public void onClick(View v){
              switch (v.getId()){
                  case R.id.buttonC: //Clear screen
                      Scr.setText("0");
                      NumberBf = 0;
                      Operation = "";
                      break;
                  case R.id.buttonAdd: //function Add
                      mMath("+");
                      break;
                  case R.id.buttonSub:
                      mMath("-");
                      break;
                  case R.id.buttonMul:
                      mMath("*");
                      break;
                  case R.id.buttonDiv:
                      mMath("/");
                      break;
                  case R.id.buttonEq:
                      mResult();
                      break;
                  case R.id.buttonSqrt:
                      fnSqrt();
                      break;
                  case R.id.buttonNp:
                      fnNp();
                      break;    
                  case R.id.buttonsquare:
                      fnSquare();
                      break;
                  default:
                      String numb = ((Button) v).getText().toString();
                      getKeyboard(numb);
                      break;
              }
          }
      }
  }
  </code></pre>