title: Having trouble making circle calculator
body: <p>So I'm trying to make a circle calculator. A person needs to add radius, diameter , S or P and program should give all answers, but when i add one thing, then program uses all formulas what I've added to program. I want program to use those specific formulas what are right for that situation, for example, when i enter radius(r) then program would use those formulas what I've added for it (//when inserting r) not other ones. 
  I hope you guys understand what i mean, sorry for my bad English, hope someone can help.</p>
  
  <pre><code>public void onButtonClick(View v) {
      EditText a1 = (EditText) findViewById(R.id.TFnum1);
      EditText a2 = (EditText) findViewById(R.id.TFnum2);
      EditText a3 = (EditText) findViewById(R.id.TFnum6);
      EditText a4 = (EditText) findViewById(R.id.TFnum7);
  
  
      TextView tv = (TextView) findViewById(R.id.TFnum7); //P
      TextView tv1 = (TextView) findViewById(R.id.TFnum6); //S
      TextView tv2 = (TextView) findViewById(R.id.TFnum2); //d
      TextView tv3 = (TextView) findViewById(R.id.TFnum1); //r
      boolean flag = false;
      double num1, num2, num6, num7, ans;
      num1 = ParseDouble(a1.getText().toString());
      num2 = ParseDouble(a2.getText().toString());
      num6 = ParseDouble(a3.getText().toString());
      num7 = ParseDouble(a4.getText().toString());
      ans = 0;
  
  
  
  
  
      //when inserting r
      //d
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = 2 * num1;
      tv2.setText(ans + "");
  
      //S
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = 3.14 * (num1 * num1);
      tv1.setText(ans + "");
  
      //P
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = num1 * 3.14 * 2;
      tv.setText(ans + "");
  
  
  
      //when inserting d
      //r
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = num2 / 2;
      tv3.setText(ans + "");
  
      //S
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = (num2 / 2) * (num2 / 2) * 3.14;
      tv1.setText(ans + "");
  
      //P
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = (num2 / 2) * 3.14 * 2;
      tv.setText(ans + "");
  
  
  
     //when inserting S
     //r
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = Math.sqrt(num6 / 3.14);
      tv3.setText(ans + "");
  
      //d
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = Math.sqrt(num6 / 3.14) * 2;
      tv2.setText(ans + "");
  
      //P
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = (Math.sqrt(num6 / 3.14)) * 2 * 3.14;
      tv.setText(ans + "");
  
  
  
      //when inserting P
      //r
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = num7 / 6.28;
      tv3.setText(ans + "");
  
      //d
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = (num7 / 6.28) * 2;
      tv2.setText(ans + "");
  
      //S
      if (v.getId() == R.id.Badd) if (num2 == 0) flag = true;
      else ans = (num7 / 6.28) * (num7 /6.28) * 3.14;
      tv1.setText(ans + "");
  }
  
  private double ParseDouble(String number) {
      if (number!= null &amp;&amp; number.length() &gt; 0) {
          try {
              return Double.parseDouble(number);
          } catch(Exception e) {
              return -1;// Will return -1 in case of exception, you can change it with another value
          }
      }
  
      return 1;
  }
  </code></pre>