title: Java Android Calculator crashes when operator is pressed before values are entered
body: <p>If I press "=", "+", "-", "*", or "/" before any numbers, my app crashes! I can't find any good answers to this and I'm not sure what I need to do.</p>
  
  <p>I've tried multiple different ways to make this calculator but I still get the same problem. I'm thinking that somehow an If statement that has to do with OnCalculation.</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
      public void onClick(View v) {
          Button button = (Button) v;
          String str = button.getText().toString();
          total += str;
          EditText edit = (EditText) findViewById(R.id.editText);
          edit.setText(total);
      }
  
      public void OnAdd(View v) {
          temp1 = Double.parseDouble(total);
          total = "";
          Button button = (Button) v;
          String str = button.getText().toString();
          sign += str;
          EditText edit = (EditText) findViewById(R.id.editText);
          edit.setText("");
      }
  
      public void OnCalculate(View v) {
          EditText edit = (EditText) findViewById(R.id.editText);
          String str2 = edit.getText().toString();
          temp2 = Double.parseDouble(str2);
          Double grand_total = 0.0;
  
          if (sign.equals("+")) {
              grand_total = temp1 + temp2;
          } else if (sign.equals("-")) {
              grand_total = temp1 - temp2;
          } else if (sign.equals("*")) {
              grand_total = temp1 * temp2;
          } else if (sign.equals("/")) {
              grand_total = temp1 / temp2;
          }
          edit.setText(grand_total + "");
          sign = "";
      }
  
  public void OnClear(View v) {
      EditText edit = (EditText)findViewById(R.id.editText);
      edit.setText("");
      total = "";
  }
  }
  </code></pre>
  
  <p><br>
   Log:</p>
  
  <pre><code>07-13 18:45:32.831 25631-25631/com.example.shelbywallace.mycalc E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                    Process: com.example.shelbywallace.mycalc, PID: 25631
                                                                                    java.lang.IllegalStateException: Could not execute method for android:onClick
                                                                                        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
                                                                                        at android.view.View.performClick(View.java:5702)
                                                                                        at android.widget.TextView.performClick(TextView.java:10888)
                                                                                        at android.view.View$PerformClick.run(View.java:22533)
                                                                                        at android.os.Handler.handleCallback(Handler.java:739)
                                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                        at android.os.Looper.loop(Looper.java:158)
                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                                                                                     Caused by: java.lang.reflect.InvocationTargetException
                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                                                                                        at android.view.View.performClick(View.java:5702) 
                                                                                        at android.widget.TextView.performClick(TextView.java:10888) 
                                                                                        at android.view.View$PerformClick.run(View.java:22533) 
                                                                                        at android.os.Handler.handleCallback(Handler.java:739) 
                                                                                        at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                                        at android.os.Looper.loop(Looper.java:158) 
                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7229) 
                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
                                                                                     Caused by: java.lang.NumberFormatException: Invalid double: ""
                                                                                        at java.lang.StringToReal.invalidReal(StringToReal.java:63)
                                                                                        at java.lang.StringToReal.parseDouble(StringToReal.java:267)
                                                                                        at java.lang.Double.parseDouble(Double.java:301)
                                                                                        at com.example.shelbywallace.mycalc.MainActivity.OnCalculate(MainActivity.java:54)
                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
                                                                                        at android.view.View.performClick(View.java:5702) 
                                                                                        at android.widget.TextView.performClick(TextView.java:10888) 
                                                                                        at android.view.View$PerformClick.run(View.java:22533) 
                                                                                        at android.os.Handler.handleCallback(Handler.java:739) 
                                                                                        at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                                        at android.os.Looper.loop(Looper.java:158) 
                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7229) 
                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
  </code></pre>